Skip to content

Commit 25abdcd

Browse files
reset state
1 parent 86535ec commit 25abdcd

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

  • src/frontend/src/routes/(needs_onboarding)/(navbar_and_footer)/upload

src/frontend/src/routes/(needs_onboarding)/(navbar_and_footer)/upload/+page.svelte

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import { markdown_to_html } from '$lib/markdown/markdown';
1111
import { Button } from '$lib/components/ui/button';
1212
import { fly, fade } from 'svelte/transition';
13+
import { onMount } from 'svelte';
1314
import { CloudOff } from '@lucide/svelte';
1415
1516
import Stage1 from './stage_1.svelte';
@@ -221,16 +222,32 @@
221222
window.history.pushState({ stage: UploadStage.Stage_3 }, '');
222223
};
223224
224-
const onReset = () => {
225+
const resetState = (historyMode: 'push' | 'replace' = 'push') => {
225226
files = [];
226227
uploadResult = null;
227228
stage = UploadStage.Stage_1;
228-
window.history.pushState({ stage: UploadStage.Stage_1 }, '');
229+
dragCounter = 0;
230+
dragActive = false;
231+
dragOverZone = false;
232+
dragOverCard = false;
233+
if (historyMode === 'replace') {
234+
window.history.replaceState({ stage: UploadStage.Stage_1 }, '');
235+
} else {
236+
window.history.pushState({ stage: UploadStage.Stage_1 }, '');
237+
}
238+
};
239+
240+
const onReset = () => {
241+
resetState('push');
229242
};
230243
231244
const handlePopState = (e: PopStateEvent) => {
232245
stage = isWhichUploadStage(e.state?.stage) ? e.state.stage : UploadStage.Stage_1;
233246
};
247+
248+
onMount(() => {
249+
resetState('replace');
250+
});
234251
</script>
235252

236253
<svelte:window

0 commit comments

Comments
 (0)