From 7b56df523bb3e4365f318f134b767c2df771379f Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Mon, 4 Sep 2023 20:02:35 +0200 Subject: [PATCH] Better mode switch message --- web/editor_ui.tsx | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/web/editor_ui.tsx b/web/editor_ui.tsx index 95e56fb..6afbcd4 100644 --- a/web/editor_ui.tsx +++ b/web/editor_ui.tsx @@ -20,6 +20,7 @@ import type { Client } from "./client.ts"; import { Panel } from "./components/panel.tsx"; import { h } from "./deps.ts"; import { async } from "https://cdn.skypack.dev/-/regenerator-runtime@v0.13.9-4Dxus9nU31cBsHxnWq2H/dist=es2020,mode=imports/optimized/regenerator-runtime.js"; +import { sleep } from "$sb/lib/async.ts"; export class MainUI { viewState: AppViewState = initialViewState; @@ -217,23 +218,19 @@ export class MainUI { const newValue = !this.editor.syncMode; if (newValue) { - if ( - await this.editor.confirm( - "This will enable local sync. Are you sure?", - ) - ) { - localStorage.setItem("syncMode", "true"); - location.reload(); - } + localStorage.setItem("syncMode", "true"); + this.editor.flashNotification( + "Now switching to sync mode, one moment please...", + ); + await sleep(1000); + location.reload(); } else { - if ( - await this.editor.confirm( - "This will disable local sync. Are you sure?", - ) - ) { - localStorage.removeItem("syncMode"); - location.reload(); - } + localStorage.removeItem("syncMode"); + this.editor.flashNotification( + "Now switching to server mode, one moment please...", + ); + await sleep(1000); + location.reload(); } })().catch(console.error); },