Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| afea4cf39f | |||
|
|
57c7ceb27a | ||
|
caa7d65b84 |
6 changed files with 16 additions and 63 deletions
|
|
@ -3,6 +3,7 @@
|
|||
"entry": [
|
||||
"src/index.{ts,tsx,js,jsx}",
|
||||
"src/main.{ts,tsx,js,jsx}",
|
||||
"apps/pwa/src/serviceWorker.ts",
|
||||
"apps/tauri/render-version.ts",
|
||||
"packages/**/*.test.ts"
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useEffect, useState } from "react";
|
||||
import { useEffect } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { setDatabaseEntry } from "@tensamin/shared/indexedDb";
|
||||
|
|
@ -6,11 +6,6 @@ import { isTauri } from "@tauri-apps/api/core";
|
|||
|
||||
import "./style.css";
|
||||
|
||||
type BeforeInstallPromptEvent = Event & {
|
||||
prompt: () => Promise<void>;
|
||||
userChoice: Promise<{ outcome: "accepted" | "dismissed" }>;
|
||||
};
|
||||
|
||||
const launchedFiles: File[] = [];
|
||||
const fileListeners = new Set<(file: File) => void>();
|
||||
|
||||
|
|
@ -66,9 +61,6 @@ async function enablePush() {
|
|||
}
|
||||
|
||||
export default function PwaRuntime() {
|
||||
const [installPrompt, setInstallPrompt] =
|
||||
useState<BeforeInstallPromptEvent | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
isTauri() ||
|
||||
|
|
@ -129,16 +121,6 @@ export default function PwaRuntime() {
|
|||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const handleInstallPrompt = (event: Event) => {
|
||||
event.preventDefault();
|
||||
setInstallPrompt(event as BeforeInstallPromptEvent);
|
||||
};
|
||||
window.addEventListener("beforeinstallprompt", handleInstallPrompt);
|
||||
return () =>
|
||||
window.removeEventListener("beforeinstallprompt", handleInstallPrompt);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const launchQueue = (
|
||||
window as Window & {
|
||||
|
|
@ -158,39 +140,6 @@ export default function PwaRuntime() {
|
|||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!installPrompt) return;
|
||||
toast("Install Tensamin for a native app experience", {
|
||||
duration: Infinity,
|
||||
action: {
|
||||
label: "Install",
|
||||
onClick: () => {
|
||||
void installPrompt.prompt().then(() => installPrompt.userChoice);
|
||||
setInstallPrompt(null);
|
||||
},
|
||||
},
|
||||
});
|
||||
}, [installPrompt]);
|
||||
|
||||
useEffect(() => {
|
||||
const isAppleMobile = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
||||
if (
|
||||
isTauri() ||
|
||||
!isAppleMobile ||
|
||||
isStandalone() ||
|
||||
localStorage.getItem("pwa-ios-install-hint")
|
||||
) {
|
||||
return;
|
||||
}
|
||||
localStorage.setItem("pwa-ios-install-hint", "shown");
|
||||
toast(
|
||||
"Install Tensamin from Safari's Share menu to enable background notifications.",
|
||||
{
|
||||
duration: 12_000,
|
||||
},
|
||||
);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
!isStandalone() ||
|
||||
|
|
|
|||
|
|
@ -34,19 +34,22 @@ function isPushPayload(value: unknown): value is PushPayload {
|
|||
const message = payload.message as
|
||||
Partial<PushPayload["message"]> | undefined;
|
||||
const secret = payload.secret as Partial<PushPayload["secret"]> | undefined;
|
||||
const stringValues = [
|
||||
payload.sender,
|
||||
message?.content,
|
||||
secret?.chatId,
|
||||
secret?.secretId,
|
||||
secret?.encryptedSecret,
|
||||
secret?.kemCiphertext,
|
||||
secret?.wrappingScheme,
|
||||
];
|
||||
return (
|
||||
payload.version === 1 &&
|
||||
typeof payload.senderId === "number" &&
|
||||
Number.isSafeInteger(payload.senderId) &&
|
||||
payload.senderId > 0 &&
|
||||
typeof payload.sender === "string" &&
|
||||
typeof message?.content === "string" &&
|
||||
typeof secret?.chatId === "string" &&
|
||||
typeof secret.secretId === "string" &&
|
||||
typeof secret.version === "number" &&
|
||||
typeof secret.encryptedSecret === "string" &&
|
||||
typeof secret.kemCiphertext === "string" &&
|
||||
typeof secret.wrappingScheme === "string"
|
||||
typeof secret?.version === "number" &&
|
||||
stringValues.every((item) => typeof item === "string")
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
2
apps/tauri/src-tauri/Cargo.lock
generated
2
apps/tauri/src-tauri/Cargo.lock
generated
|
|
@ -5286,7 +5286,7 @@ dependencies = [
|
|||
name = "tensamin"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"base64 0.23.1",
|
||||
"jni 0.22.4",
|
||||
"mtp",
|
||||
"mtp-transport 0.2.0 (git+https://git.methanium.net/methanium/mtp.git?rev=b067614a684eb1856bc5db7b3fd82148c036ce6b)",
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ tauri-build = { git = "https://github.com/tauri-apps/tauri", rev = "4af26a3f7f8b
|
|||
tauri-plugin-opener = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
base64 = "0.22"
|
||||
base64 = "0.23"
|
||||
reqwest = { version = "0.13", default-features = false, features = ["json", "rustls"] }
|
||||
tokio = { version = "1", features = ["rt-multi-thread", "sync", "time"] }
|
||||
mtp = { git = "https://git.methanium.net/methanium/mtp.git", rev = "7182272e3edb0079d7b74b45b2f62a298d2fee22", features = ["client", "crypto"] }
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
systems = [ "x86_64-linux" ];
|
||||
forAllSystems = nixpkgs.lib.genAttrs systems;
|
||||
version = "0.0.11";
|
||||
x86_64DebHash = "sha256-E4FGMpCt2ByaN6d+YzglqeA6LbhMOQmPf3UzAj7uZXE=";
|
||||
x86_64DebHash = "sha256-p/6boNv9uWTHsPTVa3EhGzr41EwRzCY/fJWlj854DVA=";
|
||||
forgejoBaseUrl = "https://git.methanium.net/tensamin/client/releases/download/${version}";
|
||||
in
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue