wip fix
This commit is contained in:
parent
4868fa7a39
commit
02193476f7
|
|
@ -21,15 +21,14 @@ export const sworkerRegister = async (react: { root: null | ReactRoot }) => {
|
|||
type: "add-cache",
|
||||
url: url,
|
||||
});
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
cacheCurrentPage();
|
||||
|
||||
const curver = localStorage.getItem("prasi-version");
|
||||
const swc = navigator.serviceWorker.controller;
|
||||
if (version !== curver && curver && react.root && swc) {
|
||||
if (version !== curver && curver && react.root && sw) {
|
||||
react.root.render(
|
||||
<>
|
||||
<Root />
|
||||
|
|
@ -42,11 +41,11 @@ export const sworkerRegister = async (react: { root: null | ReactRoot }) => {
|
|||
right: 0px;
|
||||
z-index: 999;
|
||||
`,
|
||||
"flex justify-center cursor-pointer",
|
||||
"flex justify-center cursor-pointer"
|
||||
)}
|
||||
onClick={() => {
|
||||
swc.postMessage({
|
||||
type: "force-update",
|
||||
sw.unregister().then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
if (react.root)
|
||||
react.root.render(
|
||||
|
|
@ -61,14 +60,14 @@ export const sworkerRegister = async (react: { root: null | ReactRoot }) => {
|
|||
right: 0px;
|
||||
z-index: 999;
|
||||
`,
|
||||
"flex justify-center",
|
||||
"flex justify-center"
|
||||
)}
|
||||
>
|
||||
<div className="bg-blue-400 text-white px-4 py-2 rounded-full text-sm">
|
||||
Updating App...
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
</>
|
||||
);
|
||||
}}
|
||||
>
|
||||
|
|
@ -76,7 +75,7 @@ export const sworkerRegister = async (react: { root: null | ReactRoot }) => {
|
|||
New Version Available. Click to Update
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +100,7 @@ export const sworkerRegister = async (react: { root: null | ReactRoot }) => {
|
|||
right: 0px;
|
||||
z-index: 999;
|
||||
`,
|
||||
"flex justify-center cursor-pointer",
|
||||
"flex justify-center cursor-pointer"
|
||||
)}
|
||||
>
|
||||
<div
|
||||
|
|
@ -111,7 +110,7 @@ export const sworkerRegister = async (react: { root: null | ReactRoot }) => {
|
|||
Network Failed
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -129,14 +128,14 @@ export const sworkerRegister = async (react: { root: null | ReactRoot }) => {
|
|||
right: 0px;
|
||||
z-index: 999;
|
||||
`,
|
||||
"flex justify-center",
|
||||
"flex justify-center"
|
||||
)}
|
||||
>
|
||||
<div className="bg-blue-400 text-white px-4 py-2 rounded-full text-sm">
|
||||
Updating App...
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
</>
|
||||
);
|
||||
|
||||
sw.unregister().then(() => {
|
||||
|
|
@ -162,7 +161,7 @@ export const sworkerRegister = async (react: { root: null | ReactRoot }) => {
|
|||
right: 0px;
|
||||
z-index: 999;
|
||||
`,
|
||||
"flex justify-center cursor-pointer",
|
||||
"flex justify-center cursor-pointer"
|
||||
)}
|
||||
>
|
||||
<div
|
||||
|
|
@ -173,7 +172,7 @@ export const sworkerRegister = async (react: { root: null | ReactRoot }) => {
|
|||
<span className="opacity-50">{e.data.version}</span>
|
||||
</div>
|
||||
</div>
|
||||
</>,
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -198,7 +197,7 @@ const registerServiceWorker = async () => {
|
|||
{
|
||||
type: "module",
|
||||
scope: "/",
|
||||
},
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(`Registration failed with ${error}`);
|
||||
|
|
@ -222,7 +221,7 @@ export const sworkerAddCache = (base: string) => {
|
|||
([k, v]: any) => ({
|
||||
url: v.url,
|
||||
name: k,
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
swc.postMessage({
|
||||
|
|
|
|||
Loading…
Reference in New Issue