From b92afcb1c13ce58c4d0705c6fb5dc8c2410b71c6 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Wed, 3 Jan 2024 11:10:16 +0100 Subject: [PATCH 1/2] fix selecting room from workspace list --- src/pages/workspace/WorkspacesListPage.js | 49 +++++++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/WorkspacesListPage.js b/src/pages/workspace/WorkspacesListPage.js index 67db244766a0..e58f980b50d5 100755 --- a/src/pages/workspace/WorkspacesListPage.js +++ b/src/pages/workspace/WorkspacesListPage.js @@ -27,6 +27,7 @@ import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportUtils from '@libs/ReportUtils'; import policyMemberPropType from '@pages/policyMemberPropType'; import * as ReimbursementAccountProps from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; +import reportPropTypes from '@pages/reportPropTypes'; import * as App from '@userActions/App'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; @@ -63,6 +64,9 @@ const propTypes = { /** A collection of objects for all policies which key policy member objects by accountIDs */ allPolicyMembers: PropTypes.objectOf(PropTypes.objectOf(policyMemberPropType)), + /** All reports shared with the user (coming from Onyx) */ + reports: PropTypes.objectOf(reportPropTypes), + ...withCurrentUserPersonalDetailsPropTypes, }; @@ -107,7 +111,7 @@ function dismissWorkspaceError(policyID, pendingAction) { throw new Error('Not implemented'); } -function WorkspacesListPage({policies, allPolicyMembers, reimbursementAccount, currentUserPersonalDetails}) { +function WorkspacesListPage({policies, allPolicyMembers, reimbursementAccount, currentUserPersonalDetails, reports}) { const theme = useTheme(); const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -238,6 +242,40 @@ function WorkspacesListPage({policies, allPolicyMembers, reimbursementAccount, c translate, ]); + const policyRooms = useMemo( + () => + _.reduce( + reports, + (result, report) => { + if (!report || !report.reportID) { + return result; + } + + if (!result[report.policyID]) { + // eslint-disable-next-line no-param-reassign + result[report.policyID] = {}; + } + + switch (report.chatType) { + case CONST.REPORT.CHAT_TYPE.POLICY_ADMINS: + // eslint-disable-next-line no-param-reassign + result[report.policyID].adminRoom = report.reportID; + break; + case CONST.REPORT.CHAT_TYPE.POLICY_ANNOUNCE: + // eslint-disable-next-line no-param-reassign + result[report.policyID].announceRoom = report.reportID; + break; + default: + break; + } + + return result; + }, + {}, + ), + [reports], + ); + /** * Add free policies (workspaces) to the list of menu items and returns the list of menu items * @returns {Array} the menu item list @@ -260,12 +298,12 @@ function WorkspacesListPage({policies, allPolicyMembers, reimbursementAccount, c disabled: policy.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, policyID: policy.id, reports: policy.reports, - adminRoom: policy.chatReportIDAdmins, - announceRoom: policy.chatReportIDAnnounce, + adminRoom: policyRooms[policy.id] ? policyRooms[policy.id].adminRoom : null, + announceRoom: policyRooms[policy.id] ? policyRooms[policy.id].announceRoom : null, })) .sortBy((policy) => policy.title.toLowerCase()) .value(); - }, [reimbursementAccount.errors, policies, isOffline, theme.textLight, allPolicyMembers]); + }, [reimbursementAccount.errors, policies, isOffline, theme.textLight, allPolicyMembers, policyRooms]); if (_.isEmpty(workspaces)) { return ( @@ -364,6 +402,9 @@ export default compose( userWallet: { key: ONYXKEYS.USER_WALLET, }, + reports: { + key: ONYXKEYS.COLLECTION.REPORT, + }, }), withCurrentUserPersonalDetails, )(WorkspacesListPage); From 9b319449bd3d743b474db2a629cee6cd0b038170 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Wed, 3 Jan 2024 11:18:13 +0100 Subject: [PATCH 2/2] fix paddings when scrolling workspace list --- src/pages/workspace/WorkspacesListPage.js | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/pages/workspace/WorkspacesListPage.js b/src/pages/workspace/WorkspacesListPage.js index e58f980b50d5..519cd741623c 100755 --- a/src/pages/workspace/WorkspacesListPage.js +++ b/src/pages/workspace/WorkspacesListPage.js @@ -193,11 +193,11 @@ function WorkspacesListPage({policies, allPolicyMembers, reimbursementAccount, c const listHeaderComponent = useCallback(() => { if (isSmallScreenWidth) { - return null; + return ; } return ( - + ); - }, [ - isSmallScreenWidth, - styles.flex1, - styles.flexGrow1, - styles.flexRow, - styles.gap5, - styles.mb5, - styles.mh5, - styles.ml10, - styles.mr2, - styles.pl5, - styles.textLabelSupporting, - styles.workspaceOwnerSectionTitle, - styles.workspaceTypeSectionTitle, - translate, - ]); + }, [isSmallScreenWidth, styles, translate]); const policyRooms = useMemo( () => @@ -366,7 +351,6 @@ function WorkspacesListPage({policies, allPolicyMembers, reimbursementAccount, c data={workspaces} renderItem={getMenuItem} ListHeaderComponent={listHeaderComponent} - style={styles.mt5} />