Skip to content

Commit 49b4633

Browse files
committed
fix: session propagation mistakes (#457)
1 parent 759fe8a commit 49b4633

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

web/ui/src/contexts/currentUser.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
useMeLazyQuery,
99
useUpdateSettingsMutation,
1010
} from '@graphql.d';
11+
import { useSession } from 'next-auth/react';
1112
import React, {
1213
createContext,
1314
useCallback,
@@ -35,9 +36,9 @@ const MeContext = createContext<MeContextValue>({
3536
export const MeProvider: React.FC<MeProviderProps> = ({
3637
children,
3738
apolloClient,
38-
session,
3939
}) => {
4040
const { addNotification } = useNotification();
41+
const { status } = useSession();
4142
const [me, setMe] = useState<MeQuery>({
4243
me: { settings: {} } as MeQuery['me'],
4344
myFollowings: [],
@@ -164,7 +165,7 @@ export const MeProvider: React.FC<MeProviderProps> = ({
164165

165166
return (
166167
<ConditionalWrapper
167-
condition={!!session}
168+
condition={status === 'authenticated'}
168169
trueWrapper={(c) => (
169170
<MeContext.Provider value={value}>{c}</MeContext.Provider>
170171
)}

web/ui/src/contexts/types.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { NotificationProps } from '@components/Notification/types';
22
import { MeQuery, SettingsInput } from '@graphql.d';
3+
import { Session } from 'next-auth';
34

45
export interface MeContextValue extends Omit<MeQuery, '__typename'> {
56
// Function to update the current user in the session storage
@@ -19,7 +20,7 @@ export interface MeContextValue extends Omit<MeQuery, '__typename'> {
1920

2021
type MeProviderProps = React.PropsWithChildren<{
2122
apolloClient?: ApolloClient<any>;
22-
session: Session | null;
23+
session?: Session;
2324
}>;
2425

2526
export interface NotificationContextValue {

web/ui/src/pages/_app.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ const InteractiveApp: React.FC<
2020
return (
2121
<SessionProvider session={session}>
2222
<ApolloProvider client={apolloClient}>
23-
<MeProvider apolloClient={apolloClient} session={session}>
24-
{children}
25-
</MeProvider>
23+
<MeProvider apolloClient={apolloClient}>{children}</MeProvider>
2624
</ApolloProvider>
2725
</SessionProvider>
2826
);

0 commit comments

Comments
 (0)