Skip to content

Commit

Permalink
Small optims
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Dec 12, 2024
1 parent 69c28da commit e1b96f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/lib/components/forms/ConfirmRedaction.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ This almost certainly lives in a modal.
if (result.type === "success") {
// need to invalidate before navigating
await invalidate(`document:${document.id}`);
$redactions = [];
$pending = result.data.redactions;
goto("?mode=document");
dispatch("close");
Expand Down
14 changes: 1 addition & 13 deletions src/lib/components/viewer/RedactionLayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ So this layer is only showing unsaved redactions.
export function clear() {
redactions.set([]);
pending.set([]);
}
</script>

<script lang="ts">
import { onMount } from "svelte";
import { _ } from "svelte-i18n";
import { beforeNavigate } from "$app/navigation";
export let active = false;
export let page_number: number; // 0-indexed
Expand Down Expand Up @@ -106,18 +106,6 @@ So this layer is only showing unsaved redactions.
currentRedaction = null;
}
beforeNavigate(({ cancel }) => {
// if there's redactions, confirm before navigating away
if ($redactions.length > 0) {
if (confirm($_("redact.leaveWarning"))) {
clear();
return;
} else {
cancel();
}
}
});
onMount(() => {
// before unmounting the component, clear the current redactions
return () => {
Expand Down

0 comments on commit e1b96f0

Please sign in to comment.