aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrendan F <EpicWolverine@users.noreply.github.com>2023-07-11 21:26:46 -0700
committerBrendan F <EpicWolverine@users.noreply.github.com>2023-07-11 21:26:46 -0700
commitc3eb18d4dcfe8ac359c802974984d0753d2078da (patch)
tree78b6a4b7654ed88fe824e95f0e8d0c323ae34ca9
parent8ecdf023371b3caf1e898790585a99abf9e8bc4f (diff)
Add confirmation before importing stats
-rw-r--r--src/app.tsx19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/app.tsx b/src/app.tsx
index b906eab..32559c3 100644
--- a/src/app.tsx
+++ b/src/app.tsx
@@ -26,10 +26,13 @@ function App() {
const firstRun = localStorage.getItem("firstRun") === null;
+ function reloadWithoutQueryParameters() {
+ location.replace(location.pathname);
+ }
+ const statsImportQueryParameter = new URLSearchParams(window.location.search).get('statsImport') || "";
function importStats () {
- const queryParam = new URLSearchParams(window.location.search).get('statsImport') || "";
- if (queryParam){
- const importedStats = JSON.parse(queryParam)
+ if (statsImportQueryParameter){
+ const importedStats = JSON.parse(statsImportQueryParameter)
if (Array.isArray(importedStats)) {
importedStats.forEach(day => {
if (Array.isArray(day.guesses)) {
@@ -40,10 +43,16 @@ function App() {
});
}
localStorage.setItem("stats", JSON.stringify(importedStats));
- location.replace(location.pathname);
+ reloadWithoutQueryParameters();
+ }
+ }
+ if (statsImportQueryParameter){
+ if (confirm("Do you want to import your previous stats? This will overwrite any stats on this site.")){
+ importStats()
+ } else {
+ reloadWithoutQueryParameters();
}
}
- importStats()
let stats = JSON.parse(localStorage.getItem("stats") || "{}");
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage