diff --git a/ts/sql/Server.ts b/ts/sql/Server.ts index e426714eb5..fa13e78c24 100644 --- a/ts/sql/Server.ts +++ b/ts/sql/Server.ts @@ -3498,12 +3498,12 @@ function getAdjacentMessagesByConversation( } ${ requireVisualMediaAttachments - ? sqlFragment`hasVisualMediaAttachments IS 1 AND` + ? sqlFragment`hasVisualMediaAttachments IS 1 AND isViewOnce IS 0 AND` : sqlFragment`` } ${ requireFileAttachments - ? sqlFragment`hasFileAttachments IS 1 AND` + ? sqlFragment`hasFileAttachments IS 1 AND isViewOnce IS 0 AND` : sqlFragment`` } isStory IS 0 AND diff --git a/ts/state/ducks/mediaGallery.ts b/ts/state/ducks/mediaGallery.ts index ea2d1dd6de..649be0798b 100644 --- a/ts/state/ducks/mediaGallery.ts +++ b/ts/state/ducks/mediaGallery.ts @@ -34,6 +34,7 @@ import type { MediaItemType } from '../../types/MediaItem'; import type { StateType as RootStateType } from '../reducer'; import type { MessageAttributesType } from '../../model-types'; import { MessageModel } from '../../models/messages'; +import { isTapToView } from '../selectors/message'; const log = createLogger('mediaGallery'); @@ -150,6 +151,11 @@ function _cleanVisualAttachments( .flatMap(message => { let index = 0; + // Also checked via the DB query + if (isTapToView(message.attributes)) { + return []; + } + return (message.get('attachments') || []).map( (attachment: AttachmentType): MediaType | undefined => { if ( @@ -188,6 +194,9 @@ function _cleanFileAttachments( ): ReadonlyArray { return rawDocuments .map(message => { + if (isTapToView(message.attributes)) { + return; + } const attachments = message.get('attachments') || []; const attachment = attachments[0]; if (!attachment) {