Skip to content

Commit 6deed88

Browse files
committed
Making PWA ready5
1 parent ceaa2a1 commit 6deed88

File tree

2 files changed

+86
-65
lines changed

2 files changed

+86
-65
lines changed

service-worker.js

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ const RUNTIME_CACHE = `runtime-cache-${CACHE_VERSION}`;
44

55
// List all resources you want to precache here:
66
const PRECACHE_URLS = [
7-
'/', // HTML shell
8-
'/index.html',
9-
'/offline.html',
10-
'/index.css',
11-
'/index.js',
12-
'/CountryCodes.json',
13-
'/site.webmanifest',
14-
'/identity/browserconfig.xml',
15-
'/identity/android-chrome-36x36.png',
16-
'/identity/android-chrome-48x48.png',
17-
'/identity/android-chrome-72x72.png',
18-
'/identity/android-chrome-96x96.png',
19-
'/identity/android-chrome-144x144.png',
20-
'/identity/android-chrome-192x192.png',
21-
'/identity/android-chrome-256x256.png',
22-
'/identity/android-chrome-512x512.png',
23-
'/identity/maskable-icon-512x512.png',
24-
'/identity/apple-touch-icon.png',
25-
'/identity/favicon-32x32.png',
26-
'/identity/favicon-16x16.png',
27-
'/identity/mstile-150x150.png'
7+
'/ctc/',
8+
'/ctc/index.html',
9+
'/ctc/offline.html',
10+
'/ctc/index.css',
11+
'/ctc/index.js',
12+
'/ctc/CountryCodes.json',
13+
'/ctc/site.webmanifest',
14+
'/ctc/identity/browserconfig.xml',
15+
'/ctc/identity/android-chrome-36x36.png',
16+
'/ctc/identity/android-chrome-48x48.png',
17+
'/ctc/identity/android-chrome-72x72.png',
18+
'/ctc/identity/android-chrome-96x96.png',
19+
'/ctc/identity/android-chrome-144x144.png',
20+
'/ctc/identity/android-chrome-192x192.png',
21+
'/ctc/identity/android-chrome-256x256.png',
22+
'/ctc/identity/android-chrome-512x512.png',
23+
'/ctc/identity/maskable-icon-512x512.png',
24+
'/ctc/identity/apple-touch-icon.png',
25+
'/ctc/identity/favicon-32x32.png',
26+
'/ctc/identity/favicon-16x16.png',
27+
'/ctc/identity/mstile-150x150.png'
2828
];
2929

3030
// Install: cache the application shell
@@ -58,7 +58,7 @@ self.addEventListener('fetch', event => {
5858
const url = new URL(event.request.url);
5959

6060
// 1) Navigation requests → App Shell (index.html) or offline.html
61-
if (event.request.mode === 'navigate') {
61+
if (event.request.mode === 'navigate' && url.origin === location.origin) {
6262
event.respondWith(
6363
fetch(event.request)
6464
.then(response => {
@@ -68,7 +68,10 @@ self.addEventListener('fetch', event => {
6868
return response;
6969
});
7070
})
71-
.catch(() => caches.match('/offline.html'))
71+
.catch(() => {
72+
console.log("nav offline")
73+
return caches.match('/ctc/offline.html')
74+
})
7275
);
7376
return;
7477
}

site.webmanifest

Lines changed: 60 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"name": "ClickToChat",
3-
"short_name": "C2C",
4-
"description": "Generate direct chat links for WhatsApp, Telegram, and other contacts. Fast, offline-first PWA.",
5-
"lang": "en",
6-
"start_url": "https://1bl4z3r.github.io/ctc/",
7-
"scope": "https://1bl4z3r.github.io/ctc/",
8-
"display": "standalone",
9-
"orientation": "portrait-primary",
10-
"background_color": "#0741ad",
11-
"theme_color": "#0741ad",
12-
"icons": [
2+
"name": "ClickToChat",
3+
"short_name": "C2C",
4+
"description": "Generate direct chat links for WhatsApp, Telegram, and other contacts. Fast, offline-first PWA.",
5+
"lang": "en-US",
6+
"start_url": "/ctc/",
7+
"scope": "/ctc/",
8+
"display": "standalone",
9+
"orientation": "portrait-primary",
10+
"background_color": "#0741ad",
11+
"theme_color": "#0741ad",
12+
"icons": [
1313
{
1414
"src": "identity/android-chrome-36x36.png",
1515
"sizes": "36x36",
@@ -58,34 +58,52 @@
5858
"type": "image/png",
5959
"purpose": "maskable"
6060
}
61-
],
62-
"shortcuts": [
63-
{
64-
"name": "New WhatsApp Chat",
65-
"short_name": "WhatsApp",
66-
"description": "Start a new chat on WhatsApp",
67-
"url": "/?action=whatsapp",
68-
"icons": [{ "src": "identity/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" }]
69-
},
70-
{
71-
"name": "New Telegram Chat",
72-
"short_name": "Telegram",
73-
"description": "Start a new chat on Telegram",
74-
"url": "/?action=telegram",
75-
"icons": [{ "src": "identity/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" }]
76-
},
77-
{
78-
"name": "New Signal Chat",
79-
"short_name": "Signal",
80-
"description": "Start a new chat on Signal",
81-
"url": "/?action=signal",
82-
"icons": [{ "src": "identity/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" }]
83-
}
84-
],
85-
"prefer_related_applications": false,
86-
"categories": [
87-
"productivity",
88-
"social",
89-
"utilities"
90-
]
91-
}
61+
],
62+
"shortcuts": [
63+
{
64+
"name": "New WhatsApp Chat",
65+
"short_name": "WhatsApp",
66+
"description": "Start a new chat on WhatsApp",
67+
"url": "/ctc/?action=whatsapp",
68+
"icons": [
69+
{
70+
"src": "identity/android-chrome-192x192.png",
71+
"sizes": "192x192",
72+
"type": "image/png"
73+
}
74+
]
75+
},
76+
{
77+
"name": "New Telegram Chat",
78+
"short_name": "Telegram",
79+
"description": "Start a new chat on Telegram",
80+
"url": "/ctc/?action=telegram",
81+
"icons": [
82+
{
83+
"src": "identity/android-chrome-192x192.png",
84+
"sizes": "192x192",
85+
"type": "image/png"
86+
}
87+
]
88+
},
89+
{
90+
"name": "New Signal Chat",
91+
"short_name": "Signal",
92+
"description": "Start a new chat on Signal",
93+
"url": "/?action=signal",
94+
"icons": [
95+
{
96+
"src": "identity/android-chrome-192x192.png",
97+
"sizes": "192x192",
98+
"type": "image/png"
99+
}
100+
]
101+
}
102+
],
103+
"prefer_related_applications": false,
104+
"categories": [
105+
"productivity",
106+
"social",
107+
"utilities"
108+
]
109+
}

0 commit comments

Comments
 (0)