Settings / Wallpapers: Fix auto-selecting random wallpaper (#2921)
This commit is contained in:
parent
ea6996ff83
commit
91b06c6ec9
@ -154,6 +154,7 @@ const SettingsGeneralBackground: FC<OwnProps & StateProps> = ({
|
|||||||
<div className="settings-wallpapers">
|
<div className="settings-wallpapers">
|
||||||
{loadedWallpapers.map((wallpaper) => (
|
{loadedWallpapers.map((wallpaper) => (
|
||||||
<WallpaperTile
|
<WallpaperTile
|
||||||
|
key={wallpaper.slug}
|
||||||
wallpaper={wallpaper}
|
wallpaper={wallpaper}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
isSelected={background === wallpaper.slug}
|
isSelected={background === wallpaper.slug}
|
||||||
|
|||||||
@ -44,6 +44,7 @@ const WallpaperTile: FC<OwnProps> = ({
|
|||||||
undefined,
|
undefined,
|
||||||
'slow',
|
'slow',
|
||||||
);
|
);
|
||||||
|
const isLoadingRef = useRef(false);
|
||||||
const [isLoadAllowed, setIsLoadAllowed] = useState(false);
|
const [isLoadAllowed, setIsLoadAllowed] = useState(false);
|
||||||
const {
|
const {
|
||||||
mediaData: fullMedia, loadProgress,
|
mediaData: fullMedia, loadProgress,
|
||||||
@ -68,8 +69,10 @@ const WallpaperTile: FC<OwnProps> = ({
|
|||||||
}, [fullMedia, onClick, slug]);
|
}, [fullMedia, onClick, slug]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fullMedia) {
|
// If we've clicked on a wallpaper, select it when full media is loaded
|
||||||
|
if (fullMedia && isLoadingRef.current) {
|
||||||
handleSelect();
|
handleSelect();
|
||||||
|
isLoadingRef.current = false;
|
||||||
}
|
}
|
||||||
}, [fullMedia, handleSelect]);
|
}, [fullMedia, handleSelect]);
|
||||||
|
|
||||||
@ -77,6 +80,7 @@ const WallpaperTile: FC<OwnProps> = ({
|
|||||||
if (fullMedia) {
|
if (fullMedia) {
|
||||||
handleSelect();
|
handleSelect();
|
||||||
} else {
|
} else {
|
||||||
|
isLoadingRef.current = true;
|
||||||
setIsLoadAllowed((isAllowed) => !isAllowed);
|
setIsLoadAllowed((isAllowed) => !isAllowed);
|
||||||
}
|
}
|
||||||
}, [fullMedia, handleSelect]);
|
}, [fullMedia, handleSelect]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user