From 72d30c3c06ea20a717b863d315b3c8027ab523be Mon Sep 17 00:00:00 2001 From: peterpeterparker Date: Sun, 6 Sep 2020 09:47:20 +0200 Subject: [PATCH 1/2] feat: prompt user to reload when a new version is available --- studio/src/app/app-root.tsx | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/studio/src/app/app-root.tsx b/studio/src/app/app-root.tsx index 2ca404d84..2e2d233f9 100644 --- a/studio/src/app/app-root.tsx +++ b/studio/src/app/app-root.tsx @@ -1,4 +1,4 @@ -import {Build, Component, Element, h, State} from '@stencil/core'; +import {Build, Component, Element, h, Listen, State} from '@stencil/core'; import {toastController} from '@ionic/core'; @@ -80,8 +80,35 @@ export class AppRoot { } } + @Listen('swUpdate', {target: 'window'}) + async onSWUpdate() { + const registration = await navigator.serviceWorker.getRegistration(); + + if (!registration || !registration.waiting) { + return; + } + + const toast: HTMLIonToastElement = await toastController.create({ + message: 'A new version is available, reload to update.', + buttons: [ + { + text: 'Reload', + icon: 'refresh-circle-outline', + handler: () => { + registration.waiting.postMessage('skipWaiting'); + window.location.reload(); + }, + }, + ], + position: 'top', + color: 'quaternary', + }); + + await toast.present(); + } + private async toastError(error: string) { - const popover: HTMLIonToastElement = await toastController.create({ + const toast: HTMLIonToastElement = await toastController.create({ message: error, buttons: [ { @@ -94,11 +121,11 @@ export class AppRoot { duration: 6000, }); - popover.onDidDismiss().then(() => { + toast.onDidDismiss().then(() => { errorStore.state.error = undefined; }); - await popover.present(); + await toast.present(); } private async navigate(params: NavParams) { From ce845eac7cff1deec5979eb42a7aaade921958ae Mon Sep 17 00:00:00 2001 From: peterpeterparker Date: Sun, 6 Sep 2020 09:47:54 +0200 Subject: [PATCH 2/2] chore: a smiley --- studio/src/app/pages/core/app-signin/app-signin.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/studio/src/app/pages/core/app-signin/app-signin.tsx b/studio/src/app/pages/core/app-signin/app-signin.tsx index 93f6c7ab1..26246c5fb 100644 --- a/studio/src/app/pages/core/app-signin/app-signin.tsx +++ b/studio/src/app/pages/core/app-signin/app-signin.tsx @@ -298,7 +298,7 @@ export class AppSignIn { private renderMsg() { return [ -

Oh, hi! Good to have you.

, +

Oh, hi 👋! Good to have you.

,

Sign in to unleash all features of the editor and to share your presentation online.

, ]; }