Skip to content

Commit

Permalink
Add listeners cancellation to Settings.svelte file
Browse files Browse the repository at this point in the history
  • Loading branch information
emarifer committed Dec 17, 2024
1 parent aed91b7 commit ea2000b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions frontend/src/pages/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
onMount(() => {
mounted = true;
EventsOn("saved_as", (result: string) => {
const cancelSavedAs = EventsOn("saved_as", (result: string) => {
result.includes("error")
? showError(result)
: showSuccess(`${$_("saved_as")} ${result}`);
});
EventsOn("enter_password", async () => {
const cancelEnterPassword = EventsOn("enter_password", async () => {
const { value: password } = await showQuestion(
$_("enter_password"),
);
Expand All @@ -34,7 +34,7 @@
}
});
EventsOn("imported_data", (res: string) => {
const cancelImportedData = EventsOn("imported_data", (res: string) => {
// console.log(res);
if (res === "success") {
GetLanguage().then((result) => {
Expand All @@ -56,6 +56,14 @@
showError(res);
}
});
// canceling listeners
return () => {
cancelSavedAs();
cancelEnterPassword();
cancelImportedData();
// console.log("CANCELING LISTENERS");
};
});
const showAlert = () => {
Expand Down

0 comments on commit ea2000b

Please # to comment.