mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-27 12:55:11 +01:00
Service Worker: An attempt to fix freezing UI on iOS
This commit is contained in:
parent
84e1a5b1de
commit
f4fad13266
@ -2,10 +2,12 @@ import { DEBUG } from './config';
|
||||
import { respondForProgressive } from './serviceWorker/progressive';
|
||||
import { respondWithCache, clearAssetCache } from './serviceWorker/assetCache';
|
||||
import { handlePush, handleNotificationClick, handleClientMessage } from './serviceWorker/pushNotification';
|
||||
import { pause } from './util/schedulers';
|
||||
|
||||
declare const self: ServiceWorkerGlobalScope;
|
||||
|
||||
const ASSET_CACHE_PATTERN = /[0-9a-f]{20}.*\.(js|css|woff2?|svg|png|jpg|jpeg|json|wasm)$/;
|
||||
const ACTIVATE_TIMEOUT = 3000;
|
||||
|
||||
self.addEventListener('install', (e) => {
|
||||
if (DEBUG) {
|
||||
@ -23,9 +25,17 @@ self.addEventListener('activate', (e) => {
|
||||
console.log('ServiceWorker activated');
|
||||
}
|
||||
|
||||
e.waitUntil(clearAssetCache());
|
||||
// Become available to all pages
|
||||
e.waitUntil(self.clients.claim());
|
||||
e.waitUntil(
|
||||
Promise.race([
|
||||
// An attempt to fix freezing UI on iOS
|
||||
pause(ACTIVATE_TIMEOUT),
|
||||
Promise.all([
|
||||
clearAssetCache(),
|
||||
// Become available to all pages
|
||||
self.clients.claim(),
|
||||
]),
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
|
Loading…
Reference in New Issue
Block a user