From f2733330464aeaa04ce0c87c743233072fe52ba9 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Tue, 5 Jul 2022 09:30:55 -0700 Subject: [PATCH] showMessageDetail: Add a backup in addition to transitionend handler --- ts/views/conversation_view.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ts/views/conversation_view.tsx b/ts/views/conversation_view.tsx index 27c64a044580..0df46127ad4f 100644 --- a/ts/views/conversation_view.tsx +++ b/ts/views/conversation_view.tsx @@ -114,6 +114,7 @@ import { LinkPreviewSourceType } from '../types/LinkPreview'; import { closeLightbox, showLightbox } from '../util/showLightbox'; import { saveAttachment } from '../util/saveAttachment'; import { sendDeleteForEveryoneMessage } from '../util/sendDeleteForEveryoneMessage'; +import { SECOND } from '../util/durations'; type AttachmentOptions = { messageId: string; @@ -2179,14 +2180,28 @@ export class ConversationView extends window.Backbone.View { } if (panel) { - panel.view.$el.addClass('panel--remove').one('transitionend', () => { + let timeout: ReturnType | undefined; + const removePanel = () => { + if (!timeout) { + return; + } + + clearTimeout(timeout); + timeout = undefined; + panel.view.remove(); if (this.panels.length === 0) { // Make sure poppers are positioned properly window.dispatchEvent(new Event('resize')); } - }); + }; + panel.view.$el + .addClass('panel--remove') + .one('transitionend', removePanel); + + // Backup, in case things go wrong with the transitionend event + timeout = setTimeout(removePanel, SECOND); } window.reduxActions.conversations.setSelectedConversationPanelDepth(