From 7b971e974c90061284a4ffd9fdcd7500664e967b Mon Sep 17 00:00:00 2001 From: omer Date: Sat, 7 Sep 2024 20:09:22 +0300 Subject: [PATCH 1/2] Embed selected rule in the url when sharing. --- static/scripts/shareButton.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/static/scripts/shareButton.ts b/static/scripts/shareButton.ts index dee8de1..029aeac 100644 --- a/static/scripts/shareButton.ts +++ b/static/scripts/shareButton.ts @@ -45,6 +45,7 @@ function tryLoadFromShareLink(codeMirror) { "textarea.editor-input-text", )!; inputEditor.value = decoded["input"]; + localStorage.setItem("last-selected-rule", decoded["selectedRule"]); } } @@ -54,6 +55,7 @@ function shareData(codeMirror) { input: document.querySelector( "textarea.editor-input-text", )!.value, + selectedRule: localStorage.getItem("last-selected-rule") || "", }; } From 08058c488a1c2b2863990d1658f2622b545821f7 Mon Sep 17 00:00:00 2001 From: omer Date: Wed, 11 Sep 2024 10:04:01 +0300 Subject: [PATCH 2/2] fix: check for undefined --- static/scripts/shareButton.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static/scripts/shareButton.ts b/static/scripts/shareButton.ts index 029aeac..c7d2539 100644 --- a/static/scripts/shareButton.ts +++ b/static/scripts/shareButton.ts @@ -45,7 +45,9 @@ function tryLoadFromShareLink(codeMirror) { "textarea.editor-input-text", )!; inputEditor.value = decoded["input"]; - localStorage.setItem("last-selected-rule", decoded["selectedRule"]); + if (decoded["selectedRule"]) { + localStorage.setItem("last-selected-rule", decoded["selectedRule"]); + } } }