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

Fix card not appearing after assigning on workspace members page. #185

Merged
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
13 changes: 2 additions & 11 deletions src/libs/CardUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ Onyx.connect({
},
});

let allWorkspaceCards: OnyxCollection<WorkspaceCardsList> = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST,
waitForCollectionCallback: true,
callback: (value) => {
allWorkspaceCards = value;
},
});

/**
* @returns string with a month in MM format
*/
Expand Down Expand Up @@ -437,9 +428,9 @@ function checkIfNewFeedConnected(prevFeedsData: CompanyFeeds, currentFeedsData:
};
}

function getAllCardsForWorkspace(workspaceAccountID: number): CardList {
function getAllCardsForWorkspace(workspaceAccountID: number, workspaceCardFeeds: OnyxCollection<WorkspaceCardsList>): CardList {
const cards = {};
for (const [key, values] of Object.entries(allWorkspaceCards ?? {})) {
for (const [key, values] of Object.entries(workspaceCardFeeds ?? {})) {
if (key.includes(workspaceAccountID.toString()) && values) {
const {cardList, ...rest} = values;
Object.assign(cards, rest);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM
const policyOwnerDisplayName = formatPhoneNumber(getDisplayNameOrDefault(ownerDetails)) ?? policy?.owner ?? '';
const hasMultipleFeeds = Object.values(getCompanyFeeds(cardFeeds)).filter((feed) => !feed.pending).length > 0;

const workspaceCards = getAllCardsForWorkspace(workspaceAccountID);
const [workspaceCardFeeds = {}] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST);
const workspaceCards = useMemo(() => getAllCardsForWorkspace(workspaceAccountID, workspaceCardFeeds), [workspaceAccountID, workspaceCardFeeds]);
const hasWorkspaceCardsAssigned = !!workspaceCards && !!Object.values(workspaceCards).length;

useEffect(() => {
Expand Down
Loading