Skip to content

Commit

Permalink
Merge pull request #2726 from daostack/staging
Browse files Browse the repository at this point in the history
Sprint 39
  • Loading branch information
MeyerPV authored Aug 28, 2024
2 parents 335286b + 3e2ea1f commit 417883f
Show file tree
Hide file tree
Showing 45 changed files with 1,428 additions and 971 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"identity-obj-proxy": "^3.0.0",
"jest": "^27.5.1",
"jest-extended": "^2.0.0",
"jest-fetch-mock": "^3.0.3",
"lint-staged": ">=10",
"prettier": "^2.1.1",
"prop-types": "^15.8.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ const CommonMember: FC<CommonMemberProps> = ({
</div>
</div>
</div>
<div className="members__section__common-member-date">
{joinedAt
.toDate()
.toLocaleDateString("en-US", { month: "short", day: "numeric" })}
</div>
{joinedAt && joinedAt.toDate && (
<div className="members__section__common-member-date">
{joinedAt
?.toDate()
.toLocaleDateString("en-US", { month: "short", day: "numeric" })}
</div>
)}
<MemberDropdown
notMemberCircles={notMemberCircles}
memberName={memberName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const MembersComponent: FC<MembersComponentProps> = ({ common }) => {
() =>
[...commonMembers].sort(
(commonMember, prevCommonMember) =>
prevCommonMember.joinedAt.seconds - commonMember.joinedAt.seconds,
prevCommonMember.joinedAt?.seconds - commonMember.joinedAt?.seconds,
),
[commonMembers],
);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/OldCommon/hooks/useCommonMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export const useCommonMember = (options: Options = {}): Return => {
loading: false,
fetched: true,
data: {
commonId,
...commonMember,
...generateCirclesDataForCommonMember(
governance.circles,
Expand Down Expand Up @@ -189,7 +190,7 @@ export const useCommonMember = (options: Options = {}): Return => {
}
}
},
[state, userId],
[state, userId, commonId],
);

const setCommonMember = useCallback(
Expand Down
12 changes: 9 additions & 3 deletions src/pages/OldCommon/hooks/useCommonMembers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useRef, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { trace } from "firebase/performance";
import { CommonService, Logger, UserService } from "@/services";
import { store } from "@/shared/appConfig";
import { LoadingState } from "@/shared/interfaces";
Expand All @@ -10,6 +11,7 @@ import {
selectUserStates,
} from "@/store/states";
import { useDeepCompareEffect } from "react-use";
import { perf } from "@/shared/utils/firebase";

interface Options {
commonId?: string;
Expand Down Expand Up @@ -111,6 +113,9 @@ export const useCommonMembers = ({ commonId }: Options): Return => {

(async () => {
try {
const useCommonMembersTrace = trace(perf, 'useCommonMembers');
useCommonMembersTrace.start();

const cachedUserStates = selectUserStates()(store.getState());
const hasUsersFromCache = commonMembers.some(
({ userId }) => cachedUserStates[userId]?.data,
Expand All @@ -136,7 +141,7 @@ export const useCommonMembers = ({ commonId }: Options): Return => {

const user = cachedUserStates[commonMember.userId]?.data;

return user ? [...acc, { ...commonMember, user }] : acc;
return user ? [...acc, { ...commonMember, user, commonId }] : acc;
}, []);

return {
Expand Down Expand Up @@ -173,7 +178,7 @@ export const useCommonMembers = ({ commonId }: Options): Return => {
({ uid }) => uid === commonMember.userId,
);

return user ? [...acc, { ...commonMember, user }] : acc;
return user ? [...acc, { ...commonMember, user, commonId }] : acc;
}, []);

return {
Expand All @@ -183,6 +188,7 @@ export const useCommonMembers = ({ commonId }: Options): Return => {
};
});
dispatch(cacheActions.updateUserStates(fetchedUsers));
useCommonMembersTrace.stop();
} catch (err) {
Logger.error(err);
setState((prevState) => ({
Expand All @@ -192,7 +198,7 @@ export const useCommonMembers = ({ commonId }: Options): Return => {
}));
}
})();
}, [commonMembersState.data]);
}, [commonMembersState.data, commonId]);

return {
...state,
Expand Down
13 changes: 9 additions & 4 deletions src/pages/common/components/ChatComponent/ChatComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,15 @@ export default function ChatComponent({
chatChannelId: chatChannel?.id || "",
participants: chatChannel?.participants,
});
const users = chatChannel ? chatUsers : discussionUsers;
const discussionMessages = chatChannel
? chatMessagesData.data
: discussionMessagesData.data || [];
const users = useMemo(
() => (chatChannel ? chatUsers : discussionUsers),
[chatUsers, discussionUsers, chatChannel],
);
const discussionMessages = useMemo(
() =>
chatChannel ? chatMessagesData.data : discussionMessagesData.data || [],
[chatChannel, chatMessagesData.data, discussionMessagesData.data],
);
const isFetchedDiscussionMessages =
discussionMessagesData.fetched || chatMessagesData.fetched;
const areInitialMessagesLoading = isChatChannel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const MembersComponent: FC<MembersComponentProps> = (props) => {
() =>
[...commonMembers].sort(
(commonMember, prevCommonMember) =>
prevCommonMember.joinedAt.seconds - commonMember.joinedAt.seconds,
prevCommonMember.joinedAt?.seconds - commonMember.joinedAt?.seconds,
),
[commonMembers],
);
Expand Down
Loading

0 comments on commit 417883f

Please sign in to comment.