Skip to content

Commit

Permalink
Merge pull request #13251 from Expensify/jack-keyCreatedByReportActionID
Browse files Browse the repository at this point in the history
  • Loading branch information
thienlnam authored Jan 11, 2023
2 parents fdd1a09 + 98be065 commit 55029d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ function buildOptimisticChatReport(
visibility = undefined,
notificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS,
) {
const currentTime = DateUtils.getDBTime();
return {
chatType,
hasOutstandingIOU: false,
Expand All @@ -893,8 +894,8 @@ function buildOptimisticChatReport(
lastMessageHtml: '',
lastMessageText: null,
lastReadSequenceNumber: 0,
lastActionCreated: DateUtils.getDBTime(),
lastReadTime: '',
lastReadTime: currentTime,
lastActionCreated: currentTime,
maxSequenceNumber: 0,
notificationPreference,
oldPolicyName,
Expand Down Expand Up @@ -970,6 +971,7 @@ function buildOptimisticWorkspaceChats(policyID, policyName) {
);
const announceChatReportID = announceChatData.reportID;
const announceReportActionData = buildOptimisticCreatedReportAction(announceChatData.ownerEmail);
const announceCreatedReportActionID = announceReportActionData[0].reportActionID;

const adminsChatData = buildOptimisticChatReport(
[currentUserEmail],
Expand All @@ -982,6 +984,7 @@ function buildOptimisticWorkspaceChats(policyID, policyName) {
);
const adminsChatReportID = adminsChatData.reportID;
const adminsReportActionData = buildOptimisticCreatedReportAction(adminsChatData.ownerEmail);
const adminsCreatedReportActionID = adminsReportActionData[0].reportActionID;

const expenseChatData = buildOptimisticChatReport(
[currentUserEmail],
Expand All @@ -994,17 +997,21 @@ function buildOptimisticWorkspaceChats(policyID, policyName) {
);
const expenseChatReportID = expenseChatData.reportID;
const expenseReportActionData = buildOptimisticCreatedReportAction(expenseChatData.ownerEmail);
const expenseCreatedReportActionID = expenseReportActionData[0].reportActionID;

return {
announceChatReportID,
announceChatData,
announceReportActionData,
announceCreatedReportActionID,
adminsChatReportID,
adminsChatData,
adminsReportActionData,
adminsCreatedReportActionID,
expenseChatReportID,
expenseChatData,
expenseReportActionData,
expenseCreatedReportActionID,
};
}

Expand Down
6 changes: 6 additions & 0 deletions src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,15 @@ function createWorkspace(ownerEmail = '', makeMeAdmin = false, policyName = '',
announceChatReportID,
announceChatData,
announceReportActionData,
announceCreatedReportActionID,
adminsChatReportID,
adminsChatData,
adminsReportActionData,
adminsCreatedReportActionID,
expenseChatReportID,
expenseChatData,
expenseReportActionData,
expenseCreatedReportActionID,
} = ReportUtils.buildOptimisticWorkspaceChats(policyID, workspaceName);

API.write('CreateWorkspace', {
Expand All @@ -724,6 +727,9 @@ function createWorkspace(ownerEmail = '', makeMeAdmin = false, policyName = '',
makeMeAdmin,
policyName: workspaceName,
type: CONST.POLICY.TYPE.FREE,
announceCreatedReportActionID,
adminsCreatedReportActionID,
expenseCreatedReportActionID,
},
{
optimisticData: [{
Expand Down

0 comments on commit 55029d9

Please sign in to comment.