feat: only saving token on iOS
This commit is contained in:
@ -2,6 +2,7 @@ import { type Component, type JSX, Show } from "solid-js";
|
|||||||
import { jwtDecode } from "jwt-decode";
|
import { jwtDecode } from "jwt-decode";
|
||||||
import { Navigate } from "@solidjs/router";
|
import { Navigate } from "@solidjs/router";
|
||||||
import { save_token } from "tauri-plugin-ios-shared-token-api";
|
import { save_token } from "tauri-plugin-ios-shared-token-api";
|
||||||
|
import { platform } from "@tauri-apps/plugin-os";
|
||||||
|
|
||||||
export const isTokenValid = (): boolean => {
|
export const isTokenValid = (): boolean => {
|
||||||
const token = localStorage.getItem("access");
|
const token = localStorage.getItem("access");
|
||||||
@ -29,9 +30,14 @@ export const ProtectedRoute: Component<{ children?: JSX.Element }> = (
|
|||||||
throw new Error("unreachable");
|
throw new Error("unreachable");
|
||||||
}
|
}
|
||||||
|
|
||||||
save_token(token)
|
if (platform() === "ios") {
|
||||||
.then(() => console.log("Saved token!!!"))
|
// iOS share extension is a seperate process to the App.
|
||||||
.catch((e) => console.error(e));
|
// 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 (
|
return (
|
||||||
|
Reference in New Issue
Block a user