File size: 1,252 Bytes
35909d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// static/js/sw.js
// SPDX-FileCopyrightText: Hadad <hadad@linuxmail.org>
// SPDX-License-Identifier: Apache-2.0

self.addEventListener('install', (event) => {
  event.waitUntil(
    caches.open('ChatMG-v1').then((cache) => {
      return cache.addAll([
        '/',
        '/chat',
        '/static/css/style.css',
        '/static/css/chat/style.css',
        '/static/css/sidebar.css',
        '/static/js/chat.js',
        '/static/images/mg.svg',
        '/static/images/icons/mg-48.png',
        '/static/images/icons/mg-72.png',
        '/static/images/icons/mg-96.png',
        '/static/images/icons/mg-128.png',
        '/static/images/icons/mg-192.png',
        '/static/images/icons/mg-256.png',
        '/static/images/icons/mg-384.png',
        '/static/images/icons/mg-512.png'
      ]);
    })
  );
});
self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys().then((cacheNames) => {
      return Promise.all(
        cacheNames.filter((name) => name !== 'ChatMG-v1').map((name) => caches.delete(name))
      );
    })
  );
});

self.addEventListener('fetch', (event) => {
  event.respondWith(
    caches.match(event.request).then((response) => {
      return response || fetch(event.request);
    })
  );
});