Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user profile fix #133

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading