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