From 77bdceb409e8d4e1ee6fc3f1e78dbed3bede9ac9 Mon Sep 17 00:00:00 2001 From: William Grant Date: Mon, 26 Jun 2023 10:55:14 +1000 Subject: [PATCH] fix: remove extra if statement when checking if a message is an interactionNotification --- ts/models/message.ts | 54 +++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/ts/models/message.ts b/ts/models/message.ts index b72064bd8..79f18937b 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -1381,34 +1381,32 @@ export class MessageModel extends Backbone.Model { } } - if (this.get('interactionNotification')) { - const interactionNotification = this.get('interactionNotification'); - if (interactionNotification) { - const { interactionType, interactionStatus } = interactionNotification; - - // NOTE For now we only show interaction errors in the message history - if (interactionStatus === ConversationInteractionStatus.Error) { - const convo = getConversationController().get(this.get('conversationId')); - - if (convo) { - const isGroup = !convo.isPrivate(); - const isCommunity = convo.isPublic(); - - switch (interactionType) { - case ConversationInteractionType.Hide: - return window.i18n('hideConversationFailed'); - case ConversationInteractionType.Leave: - return isCommunity - ? window.i18n('leaveCommunityFailed') - : isGroup - ? window.i18n('leaveGroupFailed') - : window.i18n('deleteConversationFailed'); - default: - assertUnreachable( - interactionType, - `Message.getDescription: Missing case error "${interactionType}"` - ); - } + const interactionNotification = this.get('interactionNotification'); + if (interactionNotification) { + const { interactionType, interactionStatus } = interactionNotification; + + // NOTE For now we only show interaction errors in the message history + if (interactionStatus === ConversationInteractionStatus.Error) { + const convo = getConversationController().get(this.get('conversationId')); + + if (convo) { + const isGroup = !convo.isPrivate(); + const isCommunity = convo.isPublic(); + + switch (interactionType) { + case ConversationInteractionType.Hide: + return window.i18n('hideConversationFailed'); + case ConversationInteractionType.Leave: + return isCommunity + ? window.i18n('leaveCommunityFailed') + : isGroup + ? window.i18n('leaveGroupFailed') + : window.i18n('deleteConversationFailed'); + default: + assertUnreachable( + interactionType, + `Message.getDescription: Missing case error "${interactionType}"` + ); } } }