showMessageDetail: Add a backup in addition to transitionend handler

This commit is contained in:
Scott Nonnenberg 2022-07-05 14:02:15 -07:00 committed by GitHub
parent 7554d8326a
commit 3c6decb3c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 2 deletions

View File

@ -116,6 +116,7 @@ import {
} from '../services/LinkPreview';
import { LinkPreviewSourceType } from '../types/LinkPreview';
import { closeLightbox, showLightbox } from '../util/showLightbox';
import { SECOND } from '../util/durations';
type AttachmentOptions = {
messageId: string;
@ -2472,14 +2473,28 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
}
if (panel) {
panel.view.$el.addClass('panel--remove').one('transitionend', () => {
let timeout: ReturnType<typeof setTimeout> | 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(