Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 110fac8de6 |
5 changed files with 14 additions and 18 deletions
|
|
@ -5,6 +5,9 @@ on:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- flake.nix
|
- flake.nix
|
||||||
|
|
||||||
|
env:
|
||||||
|
NIX_CONFIG: experimental-features = nix-command flakes
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-web:
|
build-web:
|
||||||
runs-on: nixos
|
runs-on: nixos
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ on:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- flake.nix
|
- flake.nix
|
||||||
|
|
||||||
|
env:
|
||||||
|
NIX_CONFIG: experimental-features = nix-command flakes
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-web:
|
build-web:
|
||||||
runs-on: nixos
|
runs-on: nixos
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,9 @@ export function subscribeTuFileLaunch(listener: (file: File) => void) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function isInstalledPwa() {
|
function isStandalone() {
|
||||||
return (
|
return (
|
||||||
window.matchMedia("(display-mode: standalone)").matches ||
|
window.matchMedia("(display-mode: standalone)").matches ||
|
||||||
window.matchMedia("(display-mode: window-controls-overlay)").matches ||
|
|
||||||
(navigator as Navigator & { standalone?: boolean }).standalone === true
|
(navigator as Navigator & { standalone?: boolean }).standalone === true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -61,9 +60,10 @@ async function enablePush() {
|
||||||
await setDatabaseEntry("keys", "push-subscription", subscription.toJSON());
|
await setDatabaseEntry("keys", "push-subscription", subscription.toJSON());
|
||||||
}
|
}
|
||||||
|
|
||||||
function InstalledPwaRuntime() {
|
export default function PwaRuntime() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
|
isTauri() ||
|
||||||
!("serviceWorker" in navigator) ||
|
!("serviceWorker" in navigator) ||
|
||||||
!["http:", "https:"].includes(window.location.protocol)
|
!["http:", "https:"].includes(window.location.protocol)
|
||||||
) {
|
) {
|
||||||
|
|
@ -94,15 +94,7 @@ function InstalledPwaRuntime() {
|
||||||
if (worker.state !== "installed") return;
|
if (worker.state !== "installed") return;
|
||||||
if (!navigator.serviceWorker.controller) {
|
if (!navigator.serviceWorker.controller) {
|
||||||
toast.success("Tensamin is ready for offline startup");
|
toast.success("Tensamin is ready for offline startup");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
toast("A Tensamin update is ready", {
|
|
||||||
duration: Infinity,
|
|
||||||
action: {
|
|
||||||
label: "Update",
|
|
||||||
onClick: () => worker.postMessage({ type: "SKIP_WAITING" }),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
if (registration.installing) watchWorker(registration.installing);
|
if (registration.installing) watchWorker(registration.installing);
|
||||||
|
|
@ -142,6 +134,7 @@ function InstalledPwaRuntime() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
|
!isStandalone() ||
|
||||||
!("Notification" in window) ||
|
!("Notification" in window) ||
|
||||||
Notification.permission !== "default" ||
|
Notification.permission !== "default" ||
|
||||||
localStorage.getItem("pwa-push-hint")
|
localStorage.getItem("pwa-push-hint")
|
||||||
|
|
@ -170,6 +163,7 @@ function InstalledPwaRuntime() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
|
isStandalone() &&
|
||||||
"Notification" in window &&
|
"Notification" in window &&
|
||||||
Notification.permission === "granted" &&
|
Notification.permission === "granted" &&
|
||||||
import.meta.env.VITE_WEB_PUSH_PUBLIC_KEY
|
import.meta.env.VITE_WEB_PUSH_PUBLIC_KEY
|
||||||
|
|
@ -182,8 +176,3 @@ function InstalledPwaRuntime() {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PwaRuntime() {
|
|
||||||
if (isTauri() || !isInstalledPwa()) return null;
|
|
||||||
return <InstalledPwaRuntime />;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,6 @@ export function tensaminPwa(): Plugin[] {
|
||||||
filename: "serviceWorker.ts",
|
filename: "serviceWorker.ts",
|
||||||
injectRegister: null,
|
injectRegister: null,
|
||||||
registerType: "prompt",
|
registerType: "prompt",
|
||||||
buildBase: "/",
|
|
||||||
manifestFilename: "manifest.json",
|
manifestFilename: "manifest.json",
|
||||||
includeAssets: ["favicon.ico", "icons/*.png"],
|
includeAssets: ["favicon.ico", "icons/*.png"],
|
||||||
manifest: {
|
manifest: {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
systems = [ "x86_64-linux" ];
|
systems = [ "x86_64-linux" ];
|
||||||
forAllSystems = nixpkgs.lib.genAttrs systems;
|
forAllSystems = nixpkgs.lib.genAttrs systems;
|
||||||
version = "0.0.11";
|
version = "0.0.11";
|
||||||
x86_64DebHash = "sha256-iMEgdjY8Ghlx6K/YzKC5JAZbeHNJDIFHm8MKmM4efaI=";
|
x86_64DebHash = "sha256-p/6boNv9uWTHsPTVa3EhGzr41EwRzCY/fJWlj854DVA=";
|
||||||
forgejoBaseUrl = "https://git.methanium.net/tensamin/client/releases/download/${version}";
|
forgejoBaseUrl = "https://git.methanium.net/tensamin/client/releases/download/${version}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
@ -63,6 +63,7 @@
|
||||||
pipewire
|
pipewire
|
||||||
systemd
|
systemd
|
||||||
wayland
|
wayland
|
||||||
|
webkitgtk_4_1
|
||||||
libX11
|
libX11
|
||||||
libXScrnSaver
|
libXScrnSaver
|
||||||
libXcomposite
|
libXcomposite
|
||||||
|
|
@ -184,6 +185,7 @@
|
||||||
pipewire
|
pipewire
|
||||||
systemd
|
systemd
|
||||||
wayland
|
wayland
|
||||||
|
webkitgtk_4_1
|
||||||
libX11
|
libX11
|
||||||
libXScrnSaver
|
libXScrnSaver
|
||||||
libXcomposite
|
libXcomposite
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue