Message: If collapsed in group, remove top margin on link previews

This commit is contained in:
Scott Nonnenberg 2022-06-13 14:29:10 -07:00 committed by GitHub
parent 410bc52fd0
commit e18510e41c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1009 additions and 1185 deletions

View File

@ -6,8 +6,8 @@
.container { .container {
align-content: stretch; align-content: stretch;
align-items: stretch; align-items: stretch;
height: 100vh; height: 100%;
width: 100vw; width: 100%;
} }
.dark-theme { .dark-theme {

File diff suppressed because it is too large Load Diff

View File

@ -1147,7 +1147,9 @@ export class Message extends React.PureComponent<Props, State> {
const withContentAbove = const withContentAbove =
Boolean(quote) || Boolean(quote) ||
(conversationType === 'group' && direction === 'incoming'); (!shouldCollapseAbove &&
conversationType === 'group' &&
direction === 'incoming');
const previewHasImage = isImageAttachment(first.image); const previewHasImage = isImageAttachment(first.image);
const isFullSizeImage = shouldUseFullSizeLinkPreviewImage(first); const isFullSizeImage = shouldUseFullSizeLinkPreviewImage(first);

View File

@ -4,6 +4,7 @@
import { compact, isNumber, throttle, debounce } from 'lodash'; import { compact, isNumber, throttle, debounce } from 'lodash';
import { batch as batchDispatch } from 'react-redux'; import { batch as batchDispatch } from 'react-redux';
import PQueue from 'p-queue'; import PQueue from 'p-queue';
import { v4 as generateGuid } from 'uuid';
import type { import type {
ConversationAttributesType, ConversationAttributesType,
@ -2590,7 +2591,7 @@ export class ConversationModel extends window.Backbone
}); });
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const { VERIFIED, UNVERIFIED } = this.verifiedEnum!; const { VERIFIED, DEFAULT } = this.verifiedEnum!;
if (!isDirectConversation(this.attributes)) { if (!isDirectConversation(this.attributes)) {
throw new Error( throw new Error(
@ -2641,7 +2642,7 @@ export class ConversationModel extends window.Backbone
const didVerifiedChange = beginningVerified !== verified; const didVerifiedChange = beginningVerified !== verified;
const isExplicitUserAction = !options.viaStorageServiceSync; const isExplicitUserAction = !options.viaStorageServiceSync;
const shouldShowFromStorageSync = const shouldShowFromStorageSync =
options.viaStorageServiceSync && verified !== UNVERIFIED; options.viaStorageServiceSync && verified !== DEFAULT;
if ( if (
// The message came from an explicit verification in a client (not // The message came from an explicit verification in a client (not
// storage service sync) // storage service sync)
@ -3011,11 +3012,8 @@ export class ConversationModel extends window.Backbone
async addVerifiedChange( async addVerifiedChange(
verifiedChangeId: string, verifiedChangeId: string,
verified: boolean, verified: boolean,
providedOptions: Record<string, unknown> options: { local?: boolean } = { local: true }
): Promise<void> { ): Promise<void> {
const options = providedOptions || {};
window._.defaults(options, { local: true });
if (isMe(this.attributes)) { if (isMe(this.attributes)) {
log.info('refusing to add verified change advisory for our own number'); log.info('refusing to add verified change advisory for our own number');
return; return;
@ -3030,30 +3028,30 @@ export class ConversationModel extends window.Backbone
lastMessage lastMessage
); );
const shouldBeUnseen = !options.local && !verified;
const timestamp = Date.now(); const timestamp = Date.now();
const message = { const message: MessageAttributesType = {
id: generateGuid(),
conversationId: this.id, conversationId: this.id,
local: options.local, local: Boolean(options.local),
readStatus: ReadStatus.Unread, readStatus: shouldBeUnseen ? ReadStatus.Unread : ReadStatus.Read,
received_at_ms: timestamp, received_at_ms: timestamp,
received_at: window.Signal.Util.incrementMessageCounter(), received_at: window.Signal.Util.incrementMessageCounter(),
seenStatus: SeenStatus.Unseen, seenStatus: shouldBeUnseen ? SeenStatus.Unseen : SeenStatus.Unseen,
sent_at: lastMessage, sent_at: lastMessage,
timestamp,
type: 'verified-change', type: 'verified-change',
verified, verified,
verifiedChanged: verifiedChangeId, verifiedChanged: verifiedChangeId,
// TODO: DESKTOP-722 };
} as unknown as MessageAttributesType;
const id = await window.Signal.Data.saveMessage(message, { await window.Signal.Data.saveMessage(message, {
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(), ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
forceSave: true,
}); });
const model = window.MessageController.register( const model = window.MessageController.register(
id, message.id,
new window.Whisper.Message({ new window.Whisper.Message(message)
...message,
id,
})
); );
this.trigger('newmessage', model); this.trigger('newmessage', model);