Skip to content

Commit 332d571

Browse files
committed
clear pending action from failure data
1 parent 24a56d4 commit 332d571

4 files changed

Lines changed: 19 additions & 9 deletions

File tree

src/libs/ReportActionsUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,7 @@ function getUpdateRoomDescriptionMessage(reportAction: ReportAction): string {
22692269

22702270
function getRoomAvatarUpdatedMessage(reportAction: ReportAction): string {
22712271
const originalMessage = getOriginalMessage(reportAction) as OriginalMessageChangeLog;
2272-
if (originalMessage?.avatarUrl) {
2272+
if (originalMessage?.avatarURL) {
22732273
// eslint-disable-next-line @typescript-eslint/no-deprecated
22742274
return translateLocal('roomChangeLog.changedRoomAvatar');
22752275
}

src/libs/ReportUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7717,7 +7717,7 @@ function buildOptimisticRoomDescriptionUpdatedReportAction(description: string):
77177717
/**
77187718
* Returns the necessary reportAction onyx data to indicate that the room avatar has been updated
77197719
*/
7720-
function buildOptimisticRoomAvatarUpdatedReportAction(avatarUrl: string): OptimisticRoomAvatarUpdatedReportAction {
7720+
function buildOptimisticRoomAvatarUpdatedReportAction(avatarURL: string): OptimisticRoomAvatarUpdatedReportAction {
77217721
const now = DateUtils.getDBTime();
77227722
return {
77237723
reportActionID: rand64(),
@@ -7727,8 +7727,8 @@ function buildOptimisticRoomAvatarUpdatedReportAction(avatarUrl: string): Optimi
77277727
message: [
77287728
{
77297729
type: CONST.REPORT.MESSAGE.TYPE.COMMENT,
7730-
text: avatarUrl ? `changed room avatar` : 'removed the room avatar',
7731-
html: avatarUrl ? `<muted-text>changed room avatar</muted-text>` : '<muted-text>removed the room avatar</muted-text>',
7730+
text: avatarURL ? `changed the room avatar` : 'removed the room avatar',
7731+
html: avatarURL ? `<muted-text>changed the room avatar</muted-text>` : '<muted-text>removed the room avatar</muted-text>',
77327732
},
77337733
],
77347734
person: [
@@ -7739,7 +7739,7 @@ function buildOptimisticRoomAvatarUpdatedReportAction(avatarUrl: string): Optimi
77397739
},
77407740
],
77417741
originalMessage: {
7742-
avatarUrl,
7742+
avatarURL,
77437743
lastModified: now,
77447744
},
77457745
created: now,

src/libs/actions/Report.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,10 +994,10 @@ function updateGroupChatAvatar(reportID: string, file?: File | CustomRNImageMani
994994
* Updates the avatar for a policy room.
995995
*/
996996
function updatePolicyRoomAvatar(reportID: string, file?: File | CustomRNImageManipulatorResult) {
997-
const avatarUrl = file?.uri ?? '';
997+
const avatarURL = file?.uri ?? '';
998998
const {optimisticData, successData, failureData} = buildUpdateReportAvatarOnyxData(reportID, file);
999999

1000-
const optimisticAction = buildOptimisticRoomAvatarUpdatedReportAction(avatarUrl);
1000+
const optimisticAction = buildOptimisticRoomAvatarUpdatedReportAction(avatarURL);
10011001
optimisticData.push({
10021002
onyxMethod: Onyx.METHOD.MERGE,
10031003
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
@@ -1011,7 +1011,7 @@ function updatePolicyRoomAvatar(reportID: string, file?: File | CustomRNImageMan
10111011
value: {
10121012
lastActorAccountID: currentUserAccountID,
10131013
lastVisibleActionCreated: optimisticAction.created,
1014-
lastMessageText: (optimisticAction?.message as Message[])?.at(0)?.text,
1014+
lastMessageText: (optimisticAction.message as Message[]).at(0)?.text,
10151015
},
10161016
});
10171017

@@ -1024,6 +1024,16 @@ function updatePolicyRoomAvatar(reportID: string, file?: File | CustomRNImageMan
10241024
},
10251025
});
10261026

1027+
failureData.push({
1028+
onyxMethod: Onyx.METHOD.MERGE,
1029+
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
1030+
value: {
1031+
[optimisticAction.reportActionID]: {
1032+
pendingAction: null,
1033+
},
1034+
},
1035+
});
1036+
10271037
const parameters: UpdateRoomAvatarParams = {reportID, file, reportActionID: optimisticAction.reportActionID};
10281038
API.write(WRITE_COMMANDS.UPDATE_ROOM_AVATAR, parameters, {optimisticData, failureData, successData});
10291039
}

src/types/onyx/OriginalMessage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ type OriginalMessageChangeLog = {
369369
categoryName?: string;
370370

371371
/** Avatar URL of workspace room */
372-
avatarUrl?: string;
372+
avatarURL?: string;
373373
};
374374

375375
/** Model of change log */

0 commit comments

Comments
 (0)