mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 09:50:15 +01:00
Addressing eslint errors
This commit is contained in:
parent
a77ad276f1
commit
b6de2a8557
4 changed files with 47 additions and 46 deletions
|
|
@ -2,11 +2,11 @@ import { mergeFileConfig } from 'librechat-data-provider';
|
|||
import { useCallback } from 'react';
|
||||
import { useGetFileConfig } from '~/data-provider';
|
||||
import {
|
||||
resizeImage,
|
||||
shouldResizeImage,
|
||||
supportsClientSideResize,
|
||||
type ResizeOptions,
|
||||
type ResizeResult,
|
||||
resizeImage,
|
||||
shouldResizeImage,
|
||||
supportsClientSideResize,
|
||||
type ResizeOptions,
|
||||
type ResizeResult,
|
||||
} from '~/utils/imageResize';
|
||||
|
||||
/**
|
||||
|
|
@ -19,6 +19,7 @@ export const useClientSideResize = () => {
|
|||
});
|
||||
|
||||
// Safe access to clientSideImageResize config with fallbacks
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
const config = (fileConfig as any)?.clientSideImageResize ?? {
|
||||
enabled: false,
|
||||
maxWidth: 1900,
|
||||
|
|
@ -66,7 +67,6 @@ export const useClientSideResize = () => {
|
|||
return { file: result.file, resized: true, result };
|
||||
} catch (error) {
|
||||
console.warn('Client-side image resizing failed:', error);
|
||||
// Return original file on error
|
||||
return { file, resized: false };
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@ export interface ResizeResult {
|
|||
* We use slightly smaller values to ensure no backend resizing is triggered
|
||||
*/
|
||||
const DEFAULT_RESIZE_OPTIONS: ResizeOptions = {
|
||||
maxWidth: 1900, // Slightly less than backend maxLongSide=2000
|
||||
maxWidth: 1900, // Slightly less than backend maxLongSide=2000
|
||||
maxHeight: 1900, // Slightly less than backend maxLongSide=2000
|
||||
quality: 0.92, // High quality while reducing file size
|
||||
format: 'jpeg', // Most compatible format
|
||||
quality: 0.92, // High quality while reducing file size
|
||||
format: 'jpeg', // Most compatible format
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -60,7 +60,7 @@ function calculateDimensions(
|
|||
maxWidth: number,
|
||||
maxHeight: number,
|
||||
): { width: number; height: number } {
|
||||
let { width, height } = { width: originalWidth, height: originalHeight };
|
||||
const { width, height } = { width: originalWidth, height: originalHeight };
|
||||
|
||||
// If image is smaller than max dimensions, don't upscale
|
||||
if (width <= maxWidth && height <= maxHeight) {
|
||||
|
|
@ -196,7 +196,8 @@ export function shouldResizeImage(
|
|||
fileSizeLimit: number = 512 * 1024 * 1024, // 512MB default
|
||||
): boolean {
|
||||
// Don't resize if file is already small
|
||||
if (file.size < fileSizeLimit * 0.1) { // Less than 10% of limit
|
||||
if (file.size < fileSizeLimit * 0.1) {
|
||||
// Less than 10% of limit
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue