@antscorp/antsomi-ui 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -28,6 +28,7 @@ import { ThumbnailCardWrapper } from './styled';
|
|
|
28
28
|
import { Button, Flex, Typography, Spin } from '../../atoms';
|
|
29
29
|
// Constants
|
|
30
30
|
import { THUMBNAIL_CARD_DEFAULT_HEIGHT, THUMBNAIL_CARD_DEFAULT_WIDTH } from './constants';
|
|
31
|
+
import { getUrlNoCache } from '@antscorp/antsomi-ui/es/utils';
|
|
31
32
|
export const ThumbnailCard = memo(props => {
|
|
32
33
|
const [modal, contextHolder] = Modal.useModal();
|
|
33
34
|
const { id, name, width = THUMBNAIL_CARD_DEFAULT_WIDTH, height = THUMBNAIL_CARD_DEFAULT_HEIGHT, thumbnail, removable = true, actionAvailable = true, showSkeleton = true, loading = false, removeModalProps, editBtnProps, previewBtnProps, onClickWrapper } = props, restOfProps = __rest(props, ["id", "name", "width", "height", "thumbnail", "removable", "actionAvailable", "showSkeleton", "loading", "removeModalProps", "editBtnProps", "previewBtnProps", "onClickWrapper"]);
|
|
@@ -52,7 +53,7 @@ export const ThumbnailCard = memo(props => {
|
|
|
52
53
|
};
|
|
53
54
|
return (React.createElement(Flex, Object.assign({ gap: 10, vertical: true }, restOfProps, { style: Object.assign({ width }, restOfProps.style) }),
|
|
54
55
|
React.createElement(ThumbnailCardWrapper, { "$showSkeleton": showSkeletonMemo, style: { height, cursor: actionAvailable ? 'default' : 'pointer' }, onClick: handleWrapperClick },
|
|
55
|
-
React.createElement("div", { className: "screen" }, thumbnail && React.createElement("img", { src: thumbnail, alt: "" })),
|
|
56
|
+
React.createElement("div", { className: "screen" }, thumbnail && React.createElement("img", { src: getUrlNoCache(thumbnail), alt: "" })),
|
|
56
57
|
actionAvailable && !loading && (React.createElement(React.Fragment, null,
|
|
57
58
|
React.createElement(Flex, { className: "center-action", align: "center", gap: 10, vertical: true },
|
|
58
59
|
React.createElement(Button, Object.assign({ type: "primary", className: "animate__animated animate__fadeIn" }, restOfEditBtnProps, { onClick: e => {
|
package/es/utils/common.d.ts
CHANGED
|
@@ -58,3 +58,4 @@ export declare const searchParamsToObject: (searchParams?: string) => Record<str
|
|
|
58
58
|
export declare const getShuffleArray: <T>(array: T[]) => T[];
|
|
59
59
|
export declare const snakeCaseToCamelCase: <T = Record<string, any>>(object: Record<string, any> | Record<string, any>[], recursive?: boolean) => T;
|
|
60
60
|
export declare const camelCaseToSnakeCase: <T = Record<string, any>>(object: Record<string, any>, recursive?: boolean) => T;
|
|
61
|
+
export declare const getUrlNoCache: (url?: string) => string | undefined;
|
package/es/utils/common.js
CHANGED
|
@@ -409,3 +409,13 @@ export const camelCaseToSnakeCase = (object, recursive = false) => {
|
|
|
409
409
|
});
|
|
410
410
|
return newObject;
|
|
411
411
|
};
|
|
412
|
+
export const getUrlNoCache = (url = '') => {
|
|
413
|
+
const currentTime = new Date();
|
|
414
|
+
const timeGenerated = Math.floor(currentTime.getTime() / 1000 - (currentTime.getTime() % 3)) * 1000;
|
|
415
|
+
const urlNoCache = url
|
|
416
|
+
? url.includes('nocache') || url.startsWith('data:image')
|
|
417
|
+
? url
|
|
418
|
+
: `${url}?nocache=${timeGenerated}`
|
|
419
|
+
: undefined;
|
|
420
|
+
return urlNoCache;
|
|
421
|
+
};
|