Reintroduce 'expired' event, simplify handling of View Once media
This commit is contained in:
@@ -52,6 +52,10 @@ class ExpiringMessagesDeletionService {
|
||||
});
|
||||
|
||||
const conversation = message.getConversation();
|
||||
|
||||
// We do this to update the UI, if this message is being displayed somewhere
|
||||
message.trigger('expired');
|
||||
|
||||
if (conversation) {
|
||||
// An expired message only counts as decrementing the message count, not
|
||||
// the sent message count
|
||||
|
@@ -21,6 +21,9 @@ async function eraseTapToViewMessages() {
|
||||
message.idForLogging()
|
||||
);
|
||||
|
||||
// We do this to update the UI, if this message is being displayed somewhere
|
||||
message.trigger('expired');
|
||||
|
||||
await message.eraseContents();
|
||||
})
|
||||
);
|
||||
|
@@ -115,11 +115,7 @@ import {
|
||||
suspendLinkPreviews,
|
||||
} from '../services/LinkPreview';
|
||||
import { LinkPreviewSourceType } from '../types/LinkPreview';
|
||||
import {
|
||||
closeLightbox,
|
||||
isLightboxOpen,
|
||||
showLightbox,
|
||||
} from '../util/showLightbox';
|
||||
import { closeLightbox, showLightbox } from '../util/showLightbox';
|
||||
|
||||
type AttachmentOptions = {
|
||||
messageId: string;
|
||||
@@ -1894,21 +1890,16 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||
|
||||
await message.markViewOnceMessageViewed();
|
||||
|
||||
this.listenTo(message, 'expired', async () => {
|
||||
log.info('displayTapToViewMessage: attempting to close lightbox');
|
||||
|
||||
// This isn't really a bullet-proof check because the lightbox could
|
||||
// be open while we're viewing a regular media message
|
||||
if (!isLightboxOpen()) {
|
||||
log.info('displayTapToViewMessage: lightbox was already closed');
|
||||
return;
|
||||
}
|
||||
|
||||
const close = (): void => {
|
||||
try {
|
||||
this.stopListening(message);
|
||||
closeLightbox();
|
||||
} finally {
|
||||
deleteTempFile(tempPath);
|
||||
}
|
||||
};
|
||||
|
||||
await deleteTempFile(tempPath);
|
||||
});
|
||||
this.listenTo(message, 'expired', close);
|
||||
this.listenTo(message, 'change', () => {
|
||||
showLightbox(getProps());
|
||||
});
|
||||
@@ -1917,9 +1908,7 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
||||
const { path, contentType } = tempAttachment;
|
||||
|
||||
return {
|
||||
close: () => {
|
||||
closeLightbox();
|
||||
},
|
||||
close,
|
||||
i18n: window.i18n,
|
||||
media: [
|
||||
{
|
||||
|
Reference in New Issue
Block a user