Skip to content

Commit

Permalink
update pwa file scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
kibagateaux committed Aug 5, 2024
1 parent 964826e commit b7afdb0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module.exports = {
resolver: {
...config.resolver,
extraNodeModules: {
...config.resolver.extraNodeModules,
stream: require.resolve('react-native-stream'),
...config.resolver.extraNodeModules,
},
},
};
7 changes: 4 additions & 3 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"type": "image/png"
}
],
"start_url": ".",
"display": "standalone",
"id": "/?source=pwa",
"start_url": "/?source=pwa",
"display": "fullscreen",
"theme_color": "pink",
"background_color": "pink"
}
}
3 changes: 2 additions & 1 deletion src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ export const saveStorage: <T>(
};

const _saveStorage = async (slot: string, val: string): Promise<void> => {
// cookies are forever Mostly so priavte keys dont get deleted. here bc gets hoisted anywauy
// cookies are forever Mostly so priavte keys dont get deleted. here bc gets hoisted anyway
// TODO chrome lets max 400 dahs. add in getStorage() or somewhere if timeLeft < 30 days -> reset cookie val
const expirationDate = new Date(2100, 0, 1).toUTCString();
switch (Platform.OS) {
case 'web':
Expand Down
9 changes: 3 additions & 6 deletions src/utils/serviceWorkerRegistration.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ const isLocalhost = Boolean(
);

export function register(config) {
if (
// process.env.NODE_ENV === 'production' &&
'serviceWorker' in navigator
) {
if (process.env.NODE_ENV !== 'test' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
Expand All @@ -33,9 +30,9 @@ export function register(config) {
return;
}

const url = process.env.PUBLIC_URL || `http://${window.location.host}`;
const scheme = window.location.hostname === 'localhost' ? 'http' : 'https';
window.addEventListener('load', () => {
const swUrl = `${url}/service-worker.js`;
const swUrl = `${scheme}://${window.location.host}/service-worker.js`;
console.log('service worker url', url, swUrl);

if (isLocalhost) {
Expand Down

0 comments on commit b7afdb0

Please sign in to comment.