fix: Fixed auto login

This commit is contained in:
florian 2023-08-13 11:15:20 +02:00
parent 973d6fc13f
commit b310efe098
3 changed files with 5 additions and 5 deletions

View File

@ -21,7 +21,7 @@ const GridView = ({ settings, images }: GridViewProps) => {
images
.filter(i => !isVideo(i.url)) // TODO: filter out video for now, since we don't have a good way to display them
.sort((a, b) => (b.timestamp && a.timestamp ? b.timestamp - a.timestamp : 0)), // sort by timestamp descending
[images]
[images, settings] // settings is not used here, but we need to include it to trigger a re-render when it changes
);
const onKeyDown = (event: KeyboardEvent) => {

View File

@ -183,7 +183,7 @@ const SlideShow = () => {
// auto login when alby is available
onLogin();
}
}, 500);
}, 100);
document.body.addEventListener('keydown', onKeyDown);
return () => {

View File

@ -7,11 +7,11 @@ declare global {
}
const useAutoLogin = () => {
const [autoLogin, setAutoLogin] = useState(false);
const [autoLogin, setAutoLogin] = useState(JSON.parse(localStorage.getItem('autoLogin') as string) as boolean | undefined);
useEffect(() => {
const disclaimerAcceptedPreviously = JSON.parse(localStorage.getItem('autoLogin') as string);
if (disclaimerAcceptedPreviously === true) {
const autoLogin = JSON.parse(localStorage.getItem('autoLogin') as string) as boolean | undefined;
if (autoLogin === true) {
setAutoLogin(true);
}
}, []);