Merge of modifications from previous web presentation implementation

This commit is contained in:
BinaryAlley committed 2024-09-26 20:01:59 +03:00
1 parent 193861c9c5
commit 4c8517bb08
10 files changed
+2453 -39

No files matched your search

-2
View File
@@ -274,8 +274,6 @@ dotnet_naming_style.local_function_style.capitalization = pascal_case
# readonly instance fields are camelCase and begin with underscore
dotnet_naming_symbols.readonly_instance_fields.applicable_kinds = field
dotnet_naming_symbols.readonly_instance_fields.required_modifiers = readonly
dotnet_naming_symbols.readonly_instance_fields.required_modifiers_style = exclude_any
dotnet_naming_symbols.readonly_instance_fields.required_modifiers = static
dotnet_naming_style.underscore_camel_case_style.capitalization = camel_case
dotnet_naming_style.underscore_camel_case_style.required_prefix = _
@@ -105,7 +105,7 @@ internal class FileProviderService : IFileProviderService
// check if the user has access permissions to the provided path
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadContents))
return Errors.Permission.UnauthorizedAccess;
return System.IO.File.ReadAllBytes(path.Path);
return File.ReadAllBytes(path.Path);
}
/// <summary>
@@ -9,6 +9,7 @@ using System;
using System.IO.Abstractions;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -43,18 +44,20 @@ public class FileTypeService : IFileTypeService
/// Determines if <paramref name="file"/> is of type image or not, and returns its type.
/// </summary>
/// <param name="file">The file to determine if it is an image or not.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing the type of image or an error.</returns>
public async Task<ErrorOr<ImageType>> GetImageTypeAsync(File file)
public async Task<ErrorOr<ImageType>> GetImageTypeAsync(File file, CancellationToken cancellationToken)
{
return await GetImageTypeAsync(file.Id).ConfigureAwait(false);
return await GetImageTypeAsync(file.Id, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Determines if a file identified by <paramref name="path"/> is of type image or not, and returns its type.
/// </summary>
/// <param name="path">The path of the file to determine if it is an image or not.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing the type of image or an error.</returns>
public async Task<ErrorOr<ImageType>> GetImageTypeAsync(FileSystemPathId path)
public async Task<ErrorOr<ImageType>> GetImageTypeAsync(FileSystemPathId path, CancellationToken cancellationToken)
{
// check if the user has access permissions to the provided path
if (!_fileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ReadContents))
@@ -65,7 +68,7 @@ public class FileTypeService : IFileTypeService
if (stream.Length < BUFFER_SIZE)
return ImageType.None;
// read only the first bytes of the file, equal to the buffer size
await stream.ReadAsync(buffer).ConfigureAwait(false);
await stream.ReadAsync(buffer, cancellationToken).ConfigureAwait(false);
byte[] firstBytes = buffer[..BUFFER_SIZE].ToArray();
// check if its a known image type, based on header bytes
ImageType type = IdentifyHeader(firstBytes);
@@ -1,8 +1,9 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Contracts.Enums.PhotoLibrary;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.Entities;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -18,14 +19,16 @@ public interface IFileTypeService
/// Determines if <paramref name="file"/> is of type image or not, and returns its type.
/// </summary>
/// <param name="file">The file to determine if it is an image or not.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing the type of image or an error.</returns>
Task<ErrorOr<ImageType>> GetImageTypeAsync(File file);
Task<ErrorOr<ImageType>> GetImageTypeAsync(File file, CancellationToken cancellationToken);
/// <summary>
/// Determines if a file identified by <paramref name="path"/> is of type image or not, and returns its type.
/// </summary>
/// <param name="path">The path of the file to determine if it is an image or not.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing the type of image or an error.</returns>
Task<ErrorOr<ImageType>> GetImageTypeAsync(FileSystemPathId path);
Task<ErrorOr<ImageType>> GetImageTypeAsync(FileSystemPathId path, CancellationToken cancellationToken);
#endregion
}
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using Lumina.Domain.Core.Aggregates.FileManagement.FileManagementAggregate.ValueObjects;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -17,15 +18,17 @@ public interface IThumbnailService
/// </summary>
/// <param name="path">String representation of the file path.</param>
/// <param name="quality">The quality of the thumbnail to get.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a collection of bytes representing the thumbnail of the file at the specified path or an error.</returns>
Task<ErrorOr<Thumbnail>> GetThumbnailAsync(string path, int quality);
Task<ErrorOr<Thumbnail>> GetThumbnailAsync(string path, int quality, CancellationToken cancellationToken);
/// <summary>
/// Gets the thumbnail of a file at the specified path.
/// </summary>
/// <param name="path">The path object.</param>
/// <param name="quality">The quality of the thumbnail to get.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a collection of bytes representing the thumbnail of the file at the specified path or an error.</returns>
Task<ErrorOr<Thumbnail>> GetThumbnailAsync(FileSystemPathId path, int quality);
Task<ErrorOr<Thumbnail>> GetThumbnailAsync(FileSystemPathId path, int quality, CancellationToken cancellationToken);
#endregion
}
}
@@ -10,6 +10,7 @@ using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Processing;
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -41,13 +42,14 @@ public class ThumbnailService : IThumbnailService
/// </summary>
/// <param name="path">String representation of the file path.</param>
/// <param name="quality">The quality of the thumbnail to get.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a collection of bytes representing the thumbnail of the file at the specified path or an error.</returns>
public async Task<ErrorOr<Thumbnail>> GetThumbnailAsync(string path, int quality)
public async Task<ErrorOr<Thumbnail>> GetThumbnailAsync(string path, int quality, CancellationToken cancellationToken)
{
ErrorOr<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
if (fileSystemPathIdResult.IsError)
return fileSystemPathIdResult.Errors;
return await GetThumbnailAsync(fileSystemPathIdResult.Value, quality);
return await GetThumbnailAsync(fileSystemPathIdResult.Value, quality, cancellationToken);
}
/// <summary>
@@ -55,11 +57,12 @@ public class ThumbnailService : IThumbnailService
/// </summary>
/// <param name="path">The path of the file for which to get the thumbnail.</param>
/// <param name="quality">The quality of the thumbnail to get.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="ErrorOr{TValue}"/> containing either a collection of bytes representing the thumbnail of the file at the specified path or an error.</returns>
public async Task<ErrorOr<Thumbnail>> GetThumbnailAsync(FileSystemPathId path, int quality)
public async Task<ErrorOr<Thumbnail>> GetThumbnailAsync(FileSystemPathId path, int quality, CancellationToken cancellationToken)
{
// first, get the type of the image file
ErrorOr<ImageType> imageTypeResult = await _environmentContext.FileTypeService.GetImageTypeAsync(path);
ErrorOr<ImageType> imageTypeResult = await _environmentContext.FileTypeService.GetImageTypeAsync(path, cancellationToken);
if (imageTypeResult.IsError)
return imageTypeResult.Errors;
if (imageTypeResult.Value != ImageType.None)
@@ -74,7 +77,7 @@ public class ThumbnailService : IThumbnailService
if (imageTypeResult.Value is ImageType.JPEG or ImageType.JPEG_CANON or ImageType.JPEG2000
or ImageType.JPEG_UNKNOWN or ImageType.PNG or ImageType.BMP
or ImageType.WEBP or ImageType.GIF or ImageType.TIFF or ImageType.TGA)
adjustedImage = await AdjustImageResolutionAsync(fileContents, imageTypeResult.Value, quality);
adjustedImage = await AdjustImageResolutionAsync(fileContents, imageTypeResult.Value, quality, cancellationToken);
return new Thumbnail(imageTypeResult.Value, adjustedImage ?? fileContents);
}
else
@@ -87,8 +90,9 @@ public class ThumbnailService : IThumbnailService
/// <param name="imageBytes">The byte array of the source image.</param>
/// <param name="imageType">The format of the image whose quality is adjusted.</param>
/// <param name="quality">A value between 1 (lowest quality) to 100 (highest quality).</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>A byte array representing the processed image.</returns>
private static async Task<byte[]> AdjustImageQualityAsync(byte[] imageBytes, ImageType imageType, int quality)
private static async Task<byte[]> AdjustImageQualityAsync(byte[] imageBytes, ImageType imageType, int quality, CancellationToken cancellationToken)
{
using MemoryStream inputMemoryStream = new(imageBytes);
using MemoryStream outputMemoryStream = new();
@@ -99,24 +103,24 @@ public class ThumbnailService : IThumbnailService
case ImageType.JPEG_CANON:
case ImageType.JPEG_UNKNOWN:
{
using Image image = await Image.LoadAsync(inputMemoryStream);
await image.SaveAsync(outputMemoryStream, new JpegEncoder() { Quality = quality });
using Image image = await Image.LoadAsync(inputMemoryStream, cancellationToken);
await image.SaveAsync(outputMemoryStream, new JpegEncoder() { Quality = quality }, cancellationToken);
break;
}
case ImageType.PNG:
{
using Image image = await Image.LoadAsync(inputMemoryStream);
using Image image = await Image.LoadAsync(inputMemoryStream, cancellationToken);
// PNG is lossless; quality adjustments don't apply in the same way - we can adjust compression
int compressionLevel = MapRange(quality, 1, 100, 1, 9);
PngEncoder encoder = new()
{ CompressionLevel = (PngCompressionLevel)compressionLevel };
await image.SaveAsync(outputMemoryStream, encoder);
await image.SaveAsync(outputMemoryStream, encoder, cancellationToken);
break;
}
case ImageType.BMP:
{
using Image image = await Image.LoadAsync(inputMemoryStream);
await image.SaveAsync(outputMemoryStream, new PngEncoder()); // convert BMP to PNG for compression
using Image image = await Image.LoadAsync(inputMemoryStream, cancellationToken);
await image.SaveAsync(outputMemoryStream, new PngEncoder(), cancellationToken); // convert BMP to PNG for compression
break;
}
default:
@@ -131,12 +135,13 @@ public class ThumbnailService : IThumbnailService
/// <param name="imageBytes">The byte array of the source image.</param>
/// <param name="imageType">The format of the image whose quality is adjusted.</param>
/// <param name="quality">A value between 1 (lowest quality) to 100 (highest quality).</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>The bytes of the adjusted image.</returns>
private static async Task<byte[]> AdjustImageResolutionAsync(byte[] imageBytes, ImageType imageType, int quality)
private static async Task<byte[]> AdjustImageResolutionAsync(byte[] imageBytes, ImageType imageType, int quality, CancellationToken cancellationToken)
{
using MemoryStream inputMemoryStream = new(imageBytes);
using MemoryStream outputMemoryStream = new();
Image image = await Image.LoadAsync(inputMemoryStream);
Image image = await Image.LoadAsync(inputMemoryStream, cancellationToken);
double ratio = quality / 100.0;
int newWidth = (int)(image.Width * ratio);
int newHeight = (int)(image.Height * ratio);
@@ -163,7 +168,7 @@ public class ThumbnailService : IThumbnailService
case ImageType.JPEG2000:
case ImageType.JPEG_CANON:
case ImageType.JPEG_UNKNOWN:
await image.SaveAsync(outputMemoryStream, image.Metadata.DecodedImageFormat!);
await image.SaveAsync(outputMemoryStream, image.Metadata.DecodedImageFormat!, cancellationToken);
break;
default:
return imageBytes; // for unsupported formats, just return the original bytes
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,7 @@
@page "/"
@using Lumina.Presentation.Web.Components
<PageTitle>Lumina - Home</PageTitle>
<FileSystemBrowser IncludeFiles="true" Path="C:\Users\ROCH\Downloads\" />
+208 -9
View File
@@ -11,8 +11,43 @@ let fileSystemExplorerContainer = null;
let visibleSelectionRectangle = null;
let selectionRectangle = null;
let scrollTimeout; // timeout to delay thumbnail loading after scrolling
let resizeTimeout; // timeout to delay thumbnail loading after resizing
let abortController; // allows the cancellation of thumbnail retrieval jobs
let hasScrolledAfterModeChange = false; // flag to track if scrolling occurred after a mode change
let showThumbnails = true; // whether to show thumbnails or not
let scrollThumbnailRetrievalTimeout = 1000; // the time span to wait after the last scroll, before getting thumbnails
let inspectFileForThumbnails = false; // whether to check the actual header bytes in order to determine if a file is an image, rather than its extension
let thumbnailsRetrievalBatchSize = 20; // the number of thumbnails to ask from the server, concurrently
let imagePreviewsQuality = 70; // the quality used for image thumbnails
let fullImageQuality = 90; // the quality used for full images
// =================== common helper function ===================
/**
* Convert Blob to Base64.
* @param {any} blob The blob to convert.
* @returns The converted Base64 string.
*/
async function blobToBase64(blob) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result.split(',')[1]);
reader.onerror = reject;
reader.readAsDataURL(blob);
});
}
/**
* Determines if the given file path corresponds to an image file.
* @param {string} filePath - The path to the file to be checked.
* @returns {boolean} True if the file path ends with an image file extension, false otherwise.
*/
function isImageFile(filePath) {
// Adjust the regex pattern to match the image file extensions you support
return /\.(jpe?g|png|gif|bmp|svg|ico|webp)$/i.test(filePath);
}
/**
* Gets the current time
* @returns the current time
@@ -217,6 +252,59 @@ function closeNavigatorPathSegments() {
checkboxes[i].checked = false;
}
/**
* Handles the scroll event for the explorer or explorerContainer.
* Clears any previous timeout and creates a new one to fetch visible items.
*/
function handleFileSystemBrowserScrollEvent() {
// clear any previously set timeouts to debounce the getVisibleItems call
if (scrollTimeout) clearTimeout(scrollTimeout);
// if there's an ongoing operation, abort it
if (abortController) {
abortController.abort();
abortController = null;
}
// set a timeout to call getVisibleItems once the user stops scrolling
scrollTimeout = setTimeout(() => {
if (showThumbnails)
getVisibleItems();
}, scrollThumbnailRetrievalTimeout);
hasScrolledAfterModeChange = true;
}
/**
* Handles the window's resize event.
* Clears any previous timeout and creates a new one to fetch file system browser visible items.
*/
function handleFileSystemBrowserResizeEvent() {
// clear any previously set timeouts to debounce the getVisibleItems call during resize
if (resizeTimeout) clearTimeout(resizeTimeout);
// if there's an ongoing operation, abort it
if (abortController) {
abortController.abort();
abortController = null;
}
// set a timeout to call getVisibleItems once the user stops resizing
resizeTimeout = setTimeout(() => {
if (showThumbnails)
getVisibleItems();
}, scrollThumbnailRetrievalTimeout);
}
/**
* Switches to a different view mode.
*/
function switchViewMode() {
hasScrolledAfterModeChange = false; // reset the flag indicating a mode change
// check if content has been scrolled after the mode change; since scroll is the one triggering thumbnails retrieval,
// and there is no initial scroll when mode is changed, we need to trigger the retrieval manually
setTimeout(() => {
if (!hasScrolledAfterModeChange && showThumbnails)
getVisibleItems();
}, 50); // wait 50ms to ensure all other events have processed
}
// =================== file system browser dialog selection ===================
/**
@@ -231,8 +319,10 @@ function initializeFileSystemBrowser(dotnetHelper) {
visibleSelectionRectangle = document.getElementById('visible-selection-rectangle');
if (!fileSystemExplorer) {
fileSystemExplorer = document.getElementById('file-system-browser-file-system-explorer');
if (fileSystemExplorer)
fileSystemExplorer.addEventListener('mouseup', fileSystemExplorerMouseUp);
if (fileSystemExplorer) {
fileSystemExplorer.addEventListener('mouseup', handleFileSystemExplorerMouseUp);
fileSystemExplorer.addEventListener('scroll', handleFileSystemBrowserScrollEvent);
}
}
// event handlers needed for selection
if (!fileSystemExplorerContainer) {
@@ -242,6 +332,7 @@ function initializeFileSystemBrowser(dotnetHelper) {
fileSystemExplorerContainer.addEventListener('mousemove', updateSelection);
fileSystemExplorerContainer.addEventListener('mouseup', endSelection);
fileSystemExplorerContainer.addEventListener('wheel', handleSelection);
fileSystemExplorerContainer.addEventListener('scroll', handleFileSystemBrowserScrollEvent);
fileSystemExplorerContainer.addEventListener('scroll', handleSelection);
}
}
@@ -273,8 +364,7 @@ function initializeFileSystemBrowser(dotnetHelper) {
dotnetHelper.invokeMethodAsync('OnDirectoryDoubleClickAsync', e.currentTarget.dataset.path);
return;
}
else
{ // files
else { // files
}
// reset the timestamp used to track double clicks
@@ -302,8 +392,7 @@ function initializeFileSystemBrowser(dotnetHelper) {
for (let i = from; i <= to; i++)
allEClassElements[i].classList.add('selected');
}
else
{ // when neither CTRL nor SHIFT keys are pressed
else { // when neither CTRL nor SHIFT keys are pressed
if (!isSelectionMode) {
// get all elements that are selected
const selectedElements = allEClassElements.filter(element => element.classList.contains('selected'));
@@ -335,10 +424,10 @@ function initializeFileSystemBrowser(dotnetHelper) {
* Handler for the mouse up event of the file system browser dialog explorer
* @param {MouseEvent} e - The mouseup event object.
*/
function fileSystemExplorerMouseUp(e) {
function handleFileSystemExplorerMouseUp(e) {
const explorerScrollbars = hasScrollbars(fileSystemExplorer);
// check if clicked on the horizontal scrollbar
if (explorerScrollbars.horizontal && e.clientY > fileSystemExplorer.getBoundingClientRect().top + fileSystemExplorer.offsetHeight - scrollbarHeight)
if (explorerScrollbars.horizontal && e.clientY > fileSystemExplorer.getBoundingClientRect().top + fileSystemExplorer.offsetHeight - scrollbarHeight)
return;
if (!e.ctrlKey && !e.shiftKey && !isSelectionMode) {
// deselect all file system elements when their explorer is clicked
@@ -504,6 +593,115 @@ function toggleSelectionMode(e) {
isSelectionMode = !isSelectionMode;
}
// =================== file system browser dialog thumbnails preview ===================
/**
* Identifies items within the explorerContainer that are either fully or partially visible.
* Items with thumbnails already retrieved are excluded.
* Populates a list of such visible items and passes them for further processing.
*/
function getVisibleItems() {
const containerRect = fileSystemExplorerContainer.getBoundingClientRect();
const visibleItems = [];
// go through each .e item which has not had its thumbnail retrieved yet
const fileElements = Array.from(fileSystemExplorer.querySelectorAll('.e:not([data-thumbnail-retrieved])[data-type="file"]'));
// if the option for checking file header bytes is disabled, filter images by extension
const itemsToProcess = inspectFileForThumbnails ? fileElements : fileElements.filter(item => isImageFile(item.getAttribute('data-path')));
itemsToProcess.forEach(item => {
const itemPath = item.getAttribute('data-path');
const itemRect = item.getBoundingClientRect();
// check if the item is fully or partially visible horizontally and vertically
const isFullyVisibleHorizontally = itemRect.left >= containerRect.left && itemRect.right <= containerRect.right;
const isFullyVisibleVertically = itemRect.top >= containerRect.top && itemRect.bottom <= containerRect.bottom;
const isPartiallyVisibleHorizontally = itemRect.left < containerRect.right && itemRect.right > containerRect.left;
const isPartiallyVisibleVertically = itemRect.top < containerRect.bottom && itemRect.bottom > containerRect.top;
// if the item is fully or partially visible in both directions, add it to our list
if ((isFullyVisibleHorizontally || isPartiallyVisibleHorizontally) &&
(isFullyVisibleVertically || isPartiallyVisibleVertically)) {
const imgElement = item.querySelector('img');
visibleItems.push({
path: itemPath,
img: imgElement
});
}
});
// process the list of visible items
processVisibleItems(visibleItems);
}
/**
* Processes a given item by retrieving its thumbnail from an API and updating the item's thumbnail image.
* If there are more items in the visibleItems list, it continues to process the next item.
* If an error occurs during the retrieval process (including an aborted fetch operation), it is handled gracefully.
* @param {Object} item - The item containing its path and corresponding image element.
* @param {Array} visibleItems - List of remaining visible items to process.
* @throws {AbortError} - Indicates the fetch operation was aborted.
* @throws {Error} - Catches and logs other errors that might occur during the thumbnail retrieval.
*/
async function processItem(item, visibleItems) {
try {
const result = await getThumbnailApiCall(item.path, imagePreviewsQuality);
// update the item's thumbnail using the retrieved data
if (typeof result.base64Data !== "undefined")
item.img.src = `data:${result.mimeType};base64,${result.base64Data}`;
item.img.closest('.e').setAttribute('data-thumbnail-retrieved', 'true');
// continue with next item if there are more in the queue
if (visibleItems.length > 0) {
const nextItem = visibleItems.shift();
processItem(nextItem, visibleItems);
}
} catch (error) {
if (error.name === 'AbortError') {
// console.log('Fetch operation was aborted.');
} else {
// on error, revert the icons to the default ones
let itemType = item.img.closest('.e').getAttribute('data-type');
if (itemType === 'directory')
item.img.src = "http://localhost:5012/images/icons/Lyra/directory.svg";
else if (itemType === 'file')
item.img.src = "http://localhost:5012/images/icons/Lyra/file.svg";
console.error('Error processing item:', error);
}
}
}
/**
* Makes an API call to retrieve a thumbnail for the given item.
* @param {string} path - The path of the item for which the thumbnail needs to be fetched.
* @returns {Promise<object>} - Returns a Promise resolving to an object containing base64Data and mimeType.
* @throws {Error} - Throws an error if the API call fails.
*/
async function getThumbnailApiCall(path, quality) {
// fetch the thumbnail for the given item from the server
const response = await fetch('http://localhost:5214/api/v1/thumbnails/get-thumbnail?path=' + encodeURIComponent(path) + '&quality=' + quality, {
signal: abortController.signal // use the abort signal
});
if (!response.ok)
throw new Error('Failed to fetch the thumbnail');
// convert the response to a JSON object
const blob = await response.blob();
const base64Data = await blobToBase64(blob);
const mimeType = response.headers.get('Content-Type');
return {
base64Data: base64Data,
mimeType: mimeType
};
}
/**
* Initiates the processing of visible items. Processing is batched based on thumbnailsRetrievalBatchSize. *
* @param {Array} visibleItemsList - List of visible items to be processed.
*/
async function processVisibleItems(visibleItemsList) {
const visibleItems = [...visibleItemsList];
abortController = new AbortController(); // create a new AbortController
// process items in batches determined by thumbnailsRetrievalBatchSize
for (let i = 0; i < Math.min(thumbnailsRetrievalBatchSize, visibleItems.length); i++) {
const item = visibleItems.shift();
processItem(item, visibleItems);
}
}
// =================== window functions ===================
/**
@@ -539,6 +737,7 @@ function windowKeyDownHandler(element, dotnetHelper) {
*/
window.addEventListener('resize', function () {
adjustDropdownHeight();
handleFileSystemBrowserResizeEvent();
// update all dropdowns' positions on resize
const dropdown = document.getElementById('navigatorDropdown');
if (dropdown) {
@@ -546,4 +745,4 @@ window.addEventListener('resize', function () {
if (pathSegmentId)
updateDropdownPosition(pathSegmentId);
}
});
});