Skip to content

Commit 84c36a5

Browse files
committed
fix: clear directory (library) state on 404
1 parent f5c82d3 commit 84c36a5

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

resources/js/stores/ContentStore.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ export const useContentStore = defineStore('Content', () => {
196196
});
197197

198198
console.error('Failed to load category:', error);
199+
clearState();
199200
return false;
200201
}
201202
}
@@ -216,6 +217,8 @@ export const useContentStore = defineStore('Content', () => {
216217

217218
if (!nextFolder?.id) {
218219
toast.add('Invalid folder', { type: 'danger', description: `The folder '${nextFolderName}' does not exist.` });
220+
stateFolder.value = emptyFolder;
221+
stateVideo.value = emptyMedia;
219222
return false;
220223
}
221224

@@ -293,18 +296,18 @@ export const useContentStore = defineStore('Content', () => {
293296
};
294297
}
295298

299+
function clearState() {
300+
stateDirectory.value = emptyLibrary;
301+
stateFolder.value = emptyFolder;
302+
stateVideo.value = emptyMedia;
303+
}
304+
296305
//#endregion
297306

298307
/**
299308
* Watches the current route and clears app state when leaving the video player page.
300309
*/
301310
watch(route, (to) => {
302-
const clearState = () => {
303-
stateDirectory.value = emptyLibrary;
304-
stateFolder.value = emptyFolder;
305-
stateVideo.value = emptyMedia;
306-
};
307-
308311
if (to.name !== 'home') {
309312
clearState();
310313
}

0 commit comments

Comments
 (0)