mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-22 13:05:18 +01:00
6ba1035b69
Closes #1168, #1169
33 lines
848 B
TypeScript
33 lines
848 B
TypeScript
import MiOS from '../mios';
|
|
import { version as current } from '../../config';
|
|
|
|
export default async function(mios: MiOS, force = false, silent = false) {
|
|
const meta = await mios.getMeta(force);
|
|
const newer = meta.version;
|
|
|
|
if (newer != current) {
|
|
localStorage.setItem('should-refresh', 'true');
|
|
localStorage.setItem('v', newer);
|
|
|
|
// Clear cache (serive 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) {
|
|
alert('%i18n:common.update-available%'.replace('{newer}', newer).replace('{current}', current));
|
|
}
|
|
|
|
return newer;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|