Skip to content

Commit

Permalink
user profile fix
Browse files Browse the repository at this point in the history
  • Loading branch information
confxsd committed Jun 30, 2024
1 parent 91a9dc5 commit 8a13653
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions web-app/src/components/layout/site/AppHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useRouter } from "next/navigation";
import { useCallback, useState } from "react";

const AppHeader = () => {
const { connect, disconnect, status, setStatus } = useAuth();
const { connect, disconnect, status, setStatus, session } = useAuth();
const router = useRouter();
const { isLanding } = useRouteParams();
const [modalVisible, setModalVisible] = useState(false);
Expand All @@ -30,7 +30,7 @@ const AppHeader = () => {
setGuestModalVisible,
} = useApp();

const { data: userProfile } = useAppSelector(selectDID);
const { userProfile } = useAppSelector(selectDID);

const handleDisconnect = useCallback(async () => {
try {
Expand Down
4 changes: 1 addition & 3 deletions web-app/src/components/sections/landing/UseCases/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ const UseCasesSection = () => {
<p className="font-secondary text-lg md:text-xl">
Index, as a discovery primitive, makes many different use-cases
possible, ranging from science, journalism, e-commerce, social and
many more. <br />
<br />
Here are four examples that we are most excited about:
many more. Here are four examples that we are most excited about:
</p>
<div id="block1" className="h-[75dvh] flex flex-row items-center">
<div className="flex flex-col gap-4">
Expand Down
4 changes: 3 additions & 1 deletion web-app/src/context/AppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ export const AppContextProvider = ({ children }: AppContextProviderProps) => {

isFetchingDIDRef.current = true;

await dispatch(fetchDID({ didID, api })).unwrap();
await dispatch(
fetchDID({ didID, api, isUser: session?.did.parent === didID }),
).unwrap();

isFetchingDIDRef.current = false;
} catch (error) {
Expand Down
5 changes: 3 additions & 2 deletions web-app/src/store/api/did.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type FetchDIDPayload = {
didID: string;
api: ApiService;
ignoreDiscoveryType?: boolean;
isUser?: boolean;
};

type FetchDIDIndexesPayload = {
Expand All @@ -33,7 +34,7 @@ type FetchDIDConversationsPayload = {
export const fetchDID = createAsyncThunk(
"did/fetchDid",
async (
{ didID, api, ignoreDiscoveryType }: FetchDIDPayload,
{ didID, api, ignoreDiscoveryType, isUser = false }: FetchDIDPayload,
{ dispatch, rejectWithValue, getState },
) => {
try {
Expand All @@ -56,7 +57,7 @@ export const fetchDID = createAsyncThunk(
}
}

return did;
return { isUser, did };
} catch (err: any) {
console.error("322 Error fetching DID:", err);
return rejectWithValue(err.response.data);
Expand Down
7 changes: 6 additions & 1 deletion web-app/src/store/slices/didSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const didSlice = createSlice({
loading: false,
error: null,
avatar: null as any,
userProfile: null as any,
},
reducers: {
setProfile: (state, action) => {
Expand Down Expand Up @@ -77,7 +78,11 @@ const didSlice = createSlice({
})
.addCase(fetchDID.fulfilled, (state, action) => {
state.loading = false;
state.data = action.payload;
const { did, isUser } = action.payload;
state.data = did;
if (isUser) {
state.userProfile = did;
}
})
.addCase(fetchDID.rejected, (state, action) => {
state.loading = false;
Expand Down

0 comments on commit 8a13653

Please sign in to comment.