This commit is contained in:
seb
2026-10-04 09:37:09 +02:00
parent da318223c1
commit dd8566eabc
3 changed files with 284 additions and 281 deletions

View File

@@ -9,7 +9,7 @@ import SettingsIcon from '@mui/icons-material/Settings';
import PointOfSaleIcon from '@mui/icons-material/PointOfSale';
import PhotoCameraIcon from '@mui/icons-material/PhotoCamera';
import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined';
import { getThumbHashDataUrl, getCachedImage, imageCache } from '../article/ThumbHashImage';
import { getThumbHashDataUrl, isImageLoaded, markImageLoaded } from '../article/ThumbHashImage';
import { thumb } from '../../api';
import { tileBaseSx } from 'dashgui/tiles';
@@ -198,7 +198,7 @@ class CategoryBackdrop extends PureComponent {
constructor(props) {
super(props);
this.thumbUrl = getThumbHashDataUrl(props.thumbHash);
this.isCached = Boolean(getCachedImage(props.fullHash));
this.isCached = isImageLoaded(props.fullHash);
}
componentDidUpdate(prevProps) {
@@ -206,21 +206,21 @@ class CategoryBackdrop extends PureComponent {
this.thumbUrl = getThumbHashDataUrl(this.props.thumbHash);
}
if (prevProps.fullHash !== this.props.fullHash) {
this.isCached = Boolean(getCachedImage(this.props.fullHash));
this.isCached = isImageLoaded(this.props.fullHash);
this.forceUpdate();
}
}
handleLoad = (e) => {
if (this.props.fullHash && e.target) {
imageCache.set(this.props.fullHash, e.target);
markImageLoaded(this.props.fullHash, e.target);
}
};
render() {
const { fullHash } = this.props;
if (!this.thumbUrl && !fullHash) return null;
const isCached = this.isCached || Boolean(getCachedImage(fullHash));
const isCached = this.isCached || isImageLoaded(fullHash);
return (
<Box sx={{ position: 'absolute', inset: 0, zIndex: 0, overflow: 'hidden' }}>
{!isCached && this.thumbUrl ? (