From cbde0bb3d1dacf8398c6ef943196113c327129bb Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 4 Sep 2019 11:32:08 -0700 Subject: [PATCH] Timeline: Handle height change due to pending voice note --- ts/shims/Whisper.ts | 9 +++++++++ ts/state/ducks/conversations.ts | 4 +++- ts/types/Attachment.ts | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ts/shims/Whisper.ts b/ts/shims/Whisper.ts index 4d4a45f402cd..4250180b764e 100644 --- a/ts/shims/Whisper.ts +++ b/ts/shims/Whisper.ts @@ -11,3 +11,12 @@ export function getBubbleProps(attributes: any) { return model.getPropsForBubble(); } + +export function isVoiceFlag(flags: any): boolean { + // @ts-ignore + const protoFlags = window.textsecure.protobuf.AttachmentPointer.Flags; + const VOICE_MESSAGE_FLAG = protoFlags.VOICE_MESSAGE; + + // tslint:disable-next-line no-bitwise + return Boolean(flags && flags & VOICE_MESSAGE_FLAG); +} diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 6a672551e57e..0259f0a2e5df 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -10,6 +10,7 @@ import { without, } from 'lodash'; import { trigger } from '../../shims/events'; +import { isVoiceFlag } from '../../shims/Whisper'; import { NoopActionType } from './noop'; import { AttachmentType, @@ -541,7 +542,8 @@ function hasMessageHeightChanged( previousAttachments[0].pending && messageAttachments[0] && (isImageAttachment(messageAttachments[0]) || - isVideoAttachment(messageAttachments[0])) && + isVideoAttachment(messageAttachments[0]) || + isVoiceFlag(messageAttachments[0].flags)) && !messageAttachments[0].pending; if (singleVisualAttachmentNoLongerPending) { return true; diff --git a/ts/types/Attachment.ts b/ts/types/Attachment.ts index cffe1a739135..b8eb2c5476d0 100644 --- a/ts/types/Attachment.ts +++ b/ts/types/Attachment.ts @@ -38,6 +38,7 @@ export interface AttachmentType { url: string; contentType: MIME.MIMEType; }; + flags?: number; thumbnail?: { height: number; width: number;