feat: only saving token on iOS

This commit is contained in:
2025-05-03 12:46:40 +01:00
parent 875d1d778c
commit e9617f86ec

View File

@ -2,6 +2,7 @@ import { type Component, type JSX, Show } from "solid-js";
import { jwtDecode } from "jwt-decode";
import { Navigate } from "@solidjs/router";
import { save_token } from "tauri-plugin-ios-shared-token-api";
import { platform } from "@tauri-apps/plugin-os";
export const isTokenValid = (): boolean => {
const token = localStorage.getItem("access");
@ -29,9 +30,14 @@ export const ProtectedRoute: Component<{ children?: JSX.Element }> = (
throw new Error("unreachable");
}
save_token(token)
.then(() => console.log("Saved token!!!"))
.catch((e) => console.error(e));
if (platform() === "ios") {
// iOS share extension is a seperate process to the App.
// Therefore, we need to share our access token somewhere both the App & Share Extension can access
// This involves App Groups.
save_token(token)
.then(() => console.log("Saved token!!!"))
.catch((e) => console.error(e));
}
}
return (