Merge remote-tracking branch 'origin/main' into fix/realtime-delta-clone-recovery-20260811
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { takeGameSessionTransfer, type GameSessionTransfer } from '@sammo-ts/common/auth/gameSessionTransfer';
|
||||
import { gatewayTrpc } from '../utils/gatewayTrpc';
|
||||
import { trpc as gameTrpc } from '../utils/trpc';
|
||||
|
||||
@@ -57,6 +58,17 @@ const readQueryParam = (key: string): string | null => {
|
||||
return value;
|
||||
};
|
||||
|
||||
const readTransferredGameSession = (): GameSessionTransfer | null => {
|
||||
if (typeof window === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return takeGameSessionTransfer(window.sessionStorage);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const isAccessToken = (token: string | null): boolean => {
|
||||
if (!token) {
|
||||
return false;
|
||||
@@ -194,6 +206,12 @@ export const useSessionStore = defineStore('session', {
|
||||
this.setGameToken(gatewayTokenFromQuery);
|
||||
}
|
||||
|
||||
const transferredGameSession = readTransferredGameSession();
|
||||
if (transferredGameSession) {
|
||||
this.setProfile(transferredGameSession.profile);
|
||||
this.setGameToken(transferredGameSession.gatewayToken);
|
||||
}
|
||||
|
||||
const storedToken = this.sessionToken ?? readStorage(SESSION_TOKEN_KEY);
|
||||
if (storedToken && storedToken !== this.sessionToken) {
|
||||
this.setSessionToken(storedToken);
|
||||
|
||||
Reference in New Issue
Block a user