showMessageDetail: Add a backup in addition to transitionend handler

This commit is contained in:
Scott Nonnenberg 2022-07-05 09:30:55 -07:00 committed by GitHub
parent 06a8362541
commit f273333046
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<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(