From 0e92fe8ebab8dec24b773a4a6f892b53d5f725cc Mon Sep 17 00:00:00 2001 From: epsilon Date: Mon, 9 Aug 2021 23:11:31 +1000 Subject: [PATCH] Settings are reset on major release --- html/popup.html | 2 +- scripts/background.js | 11 ++++++++--- scripts/popup.js | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/html/popup.html b/html/popup.html index 5238e93..e93e8d2 100644 --- a/html/popup.html +++ b/html/popup.html @@ -84,7 +84,7 @@
e.g. set it to 1% min and 99% max to find servers that are not empty and not full, or set it to 50% to 99% to find servers that are 'at least half full'. - +
diff --git a/scripts/background.js b/scripts/background.js index 414b94e..8fde963 100644 --- a/scripts/background.js +++ b/scripts/background.js @@ -7,8 +7,7 @@ chrome.runtime.onInstalled.addListener(function (details) { if (details.reason === "install") { installedExtension(thisVersion); } else if (details.reason === "update") { - const prevVersion = details.previousVersion; - updatedExtension(prevVersion, thisVersion); + updatedExtension(details.previousVersion, thisVersion); } displayMessage = details.reason; @@ -18,7 +17,13 @@ function installedExtension(version) { initSettings(); } -function updatedExtension(prevVersion, thisVersion) {} +function updatedExtension(prevVersion, thisVersion) { + //reset settings on major release + if (thisVersion.charAt(0) !== prevVersion.charAt(0)) { + chrome.storage.sync.clear(); + initSettings(); + } +} function receivedServers() { updateBadge(); diff --git a/scripts/popup.js b/scripts/popup.js index ee900ae..995e0e2 100644 --- a/scripts/popup.js +++ b/scripts/popup.js @@ -22,11 +22,11 @@ $(function () { let text = [ // `Thanks for using my extension! I hope it's been useful to you.`, - `The extension has been rewritten from scratch. As a result, you will most likely need to reset your settings from the options menu for the extension to work properly.`, + `The extension has been rewritten from scratch. As a result, your settings and favorited servers have unfortunately needed to be reset in order for the extension to work properly.`, `You can view a full changelog on the forum thread.`, `Be sure to leave a review on the store page and share it with others.`, `The extension is now open source on GitHub. Feel free to contribute or leave feedback and suggestions.`, - `Please consider supporting my work by buying me a coffee.`, + `Please consider supporting my work by buying me a coffee ☕.`, ]; InfoModal("update-modal", "Extension update", text.join("

"), 500); }