about summary refs log tree commit diff
path: root/src/state/session/index.tsx
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-05-02 18:17:53 +0100
committerGitHub <noreply@github.com>2024-05-02 18:17:53 +0100
commit5ec945b7625a8daff3baaf76826c2f9e3c12e279 (patch)
tree0de1fcb4a7350410ef7f82760707ab4422d92021 /src/state/session/index.tsx
parentdadf27fd2f417584093fb344cdacd9dbe332dade (diff)
downloadvoidsky-5ec945b7625a8daff3baaf76826c2f9e3c12e279.tar.zst
[Session] Extract resumeSession out (#3811)
Diffstat (limited to 'src/state/session/index.tsx')
-rw-r--r--src/state/session/index.tsx23
1 files changed, 1 insertions, 22 deletions
diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx
index 582680e97..64f3837c7 100644
--- a/src/state/session/index.tsx
+++ b/src/state/session/index.tsx
@@ -35,7 +35,6 @@ const PUBLIC_BSKY_AGENT = new BskyAgent({service: PUBLIC_BSKY_SERVICE})
 configureModerationForGuest()
 
 const StateContext = React.createContext<SessionStateContext>({
-  isInitialLoad: true,
   isSwitchingAccounts: false,
   accounts: [],
   currentAccount: undefined,
@@ -47,7 +46,6 @@ const ApiContext = React.createContext<SessionApiContext>({
   login: async () => {},
   logout: async () => {},
   initSession: async () => {},
-  resumeSession: async () => {},
   removeAccount: () => {},
   selectAccount: async () => {},
   updateCurrentAccount: () => {},
@@ -67,7 +65,6 @@ type State = {
 }
 
 export function Provider({children}: React.PropsWithChildren<{}>) {
-  const [isInitialLoad, setIsInitialLoad] = React.useState(true)
   const [isSwitchingAccounts, setIsSwitchingAccounts] = React.useState(false)
   const [state, setState] = React.useState<State>({
     accounts: persisted.get('session').accounts,
@@ -389,21 +386,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
     [upsertAccount, clearCurrentAccount, createPersistSessionHandler],
   )
 
-  const resumeSession = React.useCallback<SessionApiContext['resumeSession']>(
-    async account => {
-      try {
-        if (account) {
-          await initSession(account)
-        }
-      } catch (e) {
-        logger.error(`session: resumeSession failed`, {message: e})
-      } finally {
-        setIsInitialLoad(false)
-      }
-    },
-    [initSession],
-  )
-
   const removeAccount = React.useCallback<SessionApiContext['removeAccount']>(
     account => {
       setState(s => {
@@ -547,11 +529,10 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
       currentAccount: state.accounts.find(
         a => a.did === state.currentAccountDid,
       ),
-      isInitialLoad,
       isSwitchingAccounts,
       hasSession: !!state.currentAccountDid,
     }),
-    [state, isInitialLoad, isSwitchingAccounts],
+    [state, isSwitchingAccounts],
   )
 
   const api = React.useMemo(
@@ -560,7 +541,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
       login,
       logout,
       initSession,
-      resumeSession,
       removeAccount,
       selectAccount,
       updateCurrentAccount,
@@ -571,7 +551,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
       login,
       logout,
       initSession,
-      resumeSession,
       removeAccount,
       selectAccount,
       updateCurrentAccount,