Skip to content

Commit

Permalink
fix: never throw in useCurrentSession (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysu authored Aug 4, 2023
1 parent 9428efe commit 45f1ca2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/react/src/lifecycle/useCurrentSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
useSessionVar,
} from '@lens-protocol/api-bindings';
import { WalletData } from '@lens-protocol/domain/use-cases/lifecycle';
import { invariant, never } from '@lens-protocol/shared-kernel';
import { invariant } from '@lens-protocol/shared-kernel';
import { useEffect, useRef } from 'react';

import {
Expand Down Expand Up @@ -149,7 +149,12 @@ export function useCurrentSession(): ReadResult<
};
}

never('Previous data must be defined if previous session was WithProfile');
// shoudn't happen, but just in case, fallback to loading
return {
data: undefined,
error: undefined,
loading: true,
};
}

// transitioning from NotAuthenticatedSession to AuthenticatedProfileSession
Expand Down

0 comments on commit 45f1ca2

Please sign in to comment.