Skip to content

Commit

Permalink
fix common member amount on feed page
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymikhadyuk committed Sep 27, 2023
1 parent 5fb53fa commit d282b6a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 25 deletions.
1 change: 0 additions & 1 deletion src/pages/commonFeed/CommonFeedPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const renderContentWrapper: RenderCommonFeedContentWrapper = ({
headerContent={
<HeaderContent
common={commonData.common}
commonMembersAmount={commonData.commonMembersAmount}
commonMember={commonMember}
governance={commonData.governance}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ import styles from "./HeaderContent.module.scss";
interface HeaderContentProps {
className?: string;
common: Common;
commonMembersAmount: number;
commonMember: (CommonMember & CirclesPermissions) | null;
governance: Governance;
}

const HeaderContent: FC<HeaderContentProps> = (props) => {
const { className, common, commonMembersAmount, commonMember, governance } =
props;
const { className, common, commonMember, governance } = props;
const { getCommonPageAboutTabPath } = useRoutesContext();
const isMobileVersion = useIsTabletView();
const commonFollow = useCommonFollow(common.id, commonMember);
Expand Down Expand Up @@ -61,7 +59,7 @@ const HeaderContent: FC<HeaderContentProps> = (props) => {
{showFollowIcon && <StarIcon stroke="currentColor" />}
</div>
<p className={styles.commonMembersAmount}>
{commonMembersAmount} member{getPluralEnding(commonMembersAmount)}
{common.memberCount} member{getPluralEnding(common.memberCount)}
</p>
</div>
</NavLink>
Expand Down
23 changes: 10 additions & 13 deletions src/pages/commonFeed/hooks/useCommonData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@ export const useCommonData = (userId?: string): Return => {

(async () => {
try {
const [common, governance, commonMembersAmount, sharedFeedItem] =
await Promise.all([
CommonService.getCommonById(commonId),
GovernanceService.getGovernanceByCommonId(commonId),
CommonService.getCommonMembersAmount(commonId),
sharedFeedItemId
? CommonFeedService.getCommonFeedItemById(
commonId,
sharedFeedItemId,
)
: null,
]);
const [common, governance, sharedFeedItem] = await Promise.all([
CommonService.getCommonById(commonId),
GovernanceService.getGovernanceByCommonId(commonId),
sharedFeedItemId
? CommonFeedService.getCommonFeedItemById(
commonId,
sharedFeedItemId,
)
: null,
]);

if (!common) {
throw new Error(`Couldn't find common by id = ${commonId}`);
Expand Down Expand Up @@ -87,7 +85,6 @@ export const useCommonData = (userId?: string): Return => {
governance,
parentCommons,
subCommons,
commonMembersAmount,
sharedFeedItem,
rootCommon,
rootCommonGovernance,
Expand Down
1 change: 0 additions & 1 deletion src/pages/commonFeed/hooks/useCommonData/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface Data {
governance: Governance;
parentCommons: Common[];
subCommons: Common[];
commonMembersAmount: number;
sharedFeedItem: CommonFeed | null;
rootCommon?: Common | null;
rootCommonGovernance: Governance | null;
Expand Down
6 changes: 0 additions & 6 deletions src/services/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,6 @@ class CommonService {
});
};

public getCommonMembersAmount = async (commonId: string): Promise<number> => {
const snapshot = await commonMembersSubCollection(commonId).get();

return snapshot.size;
};

public leaveCircle = async (
commonId: string,
circleId: string,
Expand Down

0 comments on commit d282b6a

Please sign in to comment.