Skip to content

Commit

Permalink
update React play PWA
Browse files Browse the repository at this point in the history
add react-play logo to manifest.json, update serviceworker.js and registerServiceWorker.js script
  • Loading branch information
frankiefab100 committed Jul 20, 2022
1 parent 60e83d5 commit c1f8143
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 249 deletions.
25 changes: 0 additions & 25 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,5 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->

<script>
if ("serviceWorker" in navigator) {
window.addEventListener("load", function () {
navigator.serviceWorker
.register("worker.js")
.then(
function (registration) {
console.log(
"Worker registration successful",
registration.scope
);
},
function (err) {
console.log("Worker registration failed", err);
}
)
.catch(function (err) {
console.log(err);
});
});
} else {
console.log("Service Worker is not supported by browser.");
}
</script>
</body>
</html>
Binary file added public/logo152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/logo192.png
Binary file not shown.
Binary file added public/logo192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/logo512.png
Binary file not shown.
Binary file removed public/logo512x512.png
Binary file not shown.
16 changes: 8 additions & 8 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
"type": "image/x-icon"
},
{
"src": "maskable_icon.png",
"sizes": "64x64 32x32 24x24 16x16 512x512 192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "logo192.png",
"src": "logo192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512x512.png",
"type": "image/png",
"sizes": "512x512"
},
{
"src": "maskable_icon.png",
"sizes": "64x64 32x32 24x24 16x16 512x512 192x192",
"type": "image/png",
"purpose": "maskable"
}
],
"start_url": ".",
"start_url": "",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
Expand Down
2 changes: 1 addition & 1 deletion public/worker.js → public/serviceWorker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const CACHE_NAME = "reactplay";

const urlsToCache = ["/", "/completed"];
const urlsToCache = ["/", "./index.html"];

const self = this;

Expand Down
141 changes: 0 additions & 141 deletions src/ServiceWorkerRegistration.js

This file was deleted.

5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "index.css";
import React, { useState } from "react";
import { createRoot } from "react-dom/client";
import reportWebVitals from "reportWebVitals";
import * as ServiceWorkerRegistration from "./ServiceWorkerRegistration";
// import * as registerServiceWorker from "./registerServiceWorker";

/** removing console statement in react prod build */
if (process.env.NODE_ENV !== "development") {
Expand Down Expand Up @@ -35,7 +35,8 @@ const Index = () => {
const container = document.getElementById("root");
createRoot(container).render(<Index />);

ServiceWorkerRegistration.register();
// Makes the app to work offline and load faster
// registerServiceWorker.register();

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
Expand Down
19 changes: 19 additions & 0 deletions src/registerServiceWorker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
if ("serviceWorker" in navigator) {
window.addEventListener("load", function () {
navigator.serviceWorker
.register("./serviceWorker.js")
.then(
function (registration) {
console.log("Worker registration successful", registration.scope);
},
function (err) {
console.log("Worker registration failed", err);
}
)
.catch(function (err) {
console.log(err);
});
});
} else {
console.log("Service Worker is not supported by browser.");
}
71 changes: 0 additions & 71 deletions src/serviceWorker.js

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true
},
"include": ["src/**/*"]
"include": ["src/**/*", "public/serviceWorker.js"]
}

0 comments on commit c1f8143

Please sign in to comment.