Live video on the AT Protocol
79
fork

Configure Feed

Select the types of activity you want to include in your feed.

app: handle logging old oauth sessions back in (#237)

* app: handle old oauth sessions

* app: handle one more old did case

* app: store old did key in new variable

authored by

Eli Mallon and committed by
GitHub
2670bac8 26426ccd

+18 -11
+18 -11
js/app/features/bluesky/blueskySlice.tsx
··· 7 7 RichText, 8 8 } from "@atproto/api"; 9 9 import { ProfileViewDetailed } from "@atproto/api/dist/client/types/app/bsky/actor/defs"; 10 + import { 11 + isLink, 12 + isMention, 13 + } from "@atproto/api/dist/client/types/app/bsky/richtext/facet"; 10 14 import { bytesToMultibase, Secp256k1Keypair } from "@atproto/crypto"; 11 - import { hydrate, STORED_KEY_KEY, DID_KEY } from "features/base/baseSlice"; 15 + import { OAuthSession } from "@atproto/oauth-client"; 16 + import { DID_KEY, hydrate, STORED_KEY_KEY } from "features/base/baseSlice"; 12 17 import { openLoginLink } from "features/platform/platformSlice"; 13 18 import { 14 19 LivestreamViewHydrated, ··· 16 21 PlayersState, 17 22 } from "features/player/playerSlice"; 18 23 import { 19 - StreamplaceState, 20 24 setURL, 25 + StreamplaceState, 21 26 } from "features/streamplace/streamplaceSlice"; 27 + import Storage from "storage"; 22 28 import { 23 29 PlaceStreamChatMessage, 24 30 PlaceStreamChatProfile, 25 31 PlaceStreamKey, 26 32 PlaceStreamLivestream, 27 33 } from "streamplace"; 28 - import Storage from "storage"; 29 34 import { isWeb } from "tamagui"; 30 35 import { privateKeyToAccount } from "viem/accounts"; 31 36 import { createAppSlice } from "../../hooks/createSlice"; 37 + import { StreamplaceAgent } from "./agent"; 32 38 import { BlueskyState } from "./blueskyTypes"; 33 39 import createOAuthClient from "./oauthClient"; 34 - import { StreamplaceAgent } from "./agent"; 35 - import { 36 - isLink, 37 - isMention, 38 - } from "@atproto/api/dist/client/types/app/bsky/richtext/facet"; 39 - import { OAuthSession } from "@atproto/oauth-client"; 40 - import error from "components/error/error"; 41 40 42 41 const initialState: BlueskyState = { 43 42 status: "start", ··· 170 169 const { streamplace } = getState() as { streamplace: StreamplaceState }; 171 170 const client = await createOAuthClient(streamplace.url); 172 171 const anonPDSAgent = new StreamplaceAgent(streamplace.url); 173 - const did = await Storage.getItem(DID_KEY); 172 + const maybeDIDs = await Promise.all([ 173 + Storage.getItem(DID_KEY), 174 + Storage.getItem("@@atproto/oauth-client-browser(sub)"), 175 + Storage.getItem("@@atproto/oauth-client-react-native:did:(sub)"), 176 + ]); 177 + const did = maybeDIDs.find((d) => d !== null) || null; 174 178 let session: OAuthSession | null = null; 175 179 if (did) { 176 180 try { ··· 193 197 const { client, session, anonPDSAgent } = action.payload; 194 198 console.log("loadOAuthClient fulfilled", action.payload); 195 199 if (session) { 200 + Storage.setItem(DID_KEY, session.did).catch((e) => { 201 + console.error("Error setting did", e); 202 + }); 196 203 return { 197 204 ...state, 198 205 client: client as any,