mirror of
https://codeberg.org/valpackett/tiddlypwa.git
synced 2026-04-27 08:10:44 -07:00
Plugin: show a persistent, over-the-login-modal notification for update
This commit is contained in:
parent
0164ade50b
commit
a38c511e22
2 changed files with 19 additions and 5 deletions
|
|
@ -13,6 +13,15 @@ Formatted with `deno fmt`.
|
|||
|
||||
if (!$tw.browser) return;
|
||||
|
||||
// Do this early to make it work on login screen too
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.onmessage = (evt) => {
|
||||
if (evt.data.op == 'refresh') {
|
||||
$tw.wiki.addTiddler({ title: '$:/status/TiddlyPWAUpdateAvailable', text: 'yes' });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Patch this to make upgrading core by drag&drop reflect the version number in generated html
|
||||
$tw.utils.extractVersionInfo = () => $tw.wiki.getTiddler('$:/core').fields.version;
|
||||
Object.defineProperty($tw, 'version', { get: $tw.utils.extractVersionInfo });
|
||||
|
|
@ -346,11 +355,6 @@ Formatted with `deno fmt`.
|
|||
$tw.wiki.addTiddler({ title: '$:/status/TiddlyPWAWorkerError', text: e.message });
|
||||
$tw.notifier.display('$:/plugins/valpackett/tiddlypwa/notif-sw-error');
|
||||
}
|
||||
navigator.serviceWorker.onmessage = (evt) => {
|
||||
if (evt.data.op == 'refresh') {
|
||||
$tw.notifier.display('$:/plugins/valpackett/tiddlypwa/notif-refresh');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async _startRealtimeMonitor() {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
title: $:/plugins/valpackett/tiddlypwa/notif-refresh
|
||||
tags: $:/tags/PageTemplate
|
||||
|
||||
<$reveal type="nomatch" state="$:/temp/HideUpdate" text="yes">
|
||||
<$reveal type="match" state="$:/status/TiddlyPWAUpdateAvailable" text="yes">
|
||||
<div class="tc-plugin-reload-warning" role="alert" style="z-index:2000">
|
||||
|
||||
~TiddlyWiki has been updated, please <$button message="tiddlypwa-browser-refresh">reload the page</$button>!
|
||||
<$button set="$:/temp/HideUpdate" setTo="yes" class="tc-btn-invisible">{{$:/core/images/close-button}}</$button>
|
||||
|
||||
</div>
|
||||
</$reveal>
|
||||
</$reveal>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue