mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-27 02:06:43 -06:00
35 lines
873 B
TypeScript
35 lines
873 B
TypeScript
import { clientVersion as current } from '../../config';
|
|
|
|
export default async function($root: any, force = false, silent = false) {
|
|
const meta = await $root.getMeta(force);
|
|
const newer = meta.clientVersion;
|
|
|
|
if (newer != current) {
|
|
localStorage.setItem('should-refresh', 'true');
|
|
localStorage.setItem('v', newer);
|
|
|
|
// Clear cache (service worker)
|
|
try {
|
|
if (navigator.serviceWorker.controller) {
|
|
navigator.serviceWorker.controller.postMessage('clear');
|
|
}
|
|
|
|
navigator.serviceWorker.getRegistrations().then(registrations => {
|
|
registrations.forEach(registration => registration.unregister());
|
|
});
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
|
|
/*if (!silent) {
|
|
$root.dialog({
|
|
title: $root.$t('@.update-available-title'),
|
|
text: $root.$t('@.update-available', { newer, current })
|
|
});
|
|
}*/
|
|
|
|
return newer;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|