mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-24 10:28:03 +01:00
🎨 Autoformat code
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
import is from '@sindresorhus/is';
|
||||
|
||||
import * as GoogleChrome from '../GoogleChrome';
|
||||
import { MIMEType } from './MIME';
|
||||
|
||||
|
||||
export interface Attachment {
|
||||
fileName?: string;
|
||||
contentType?: MIMEType;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
import is from '@sindresorhus/is';
|
||||
import { Message } from './Message';
|
||||
|
||||
|
||||
interface ConversationLastMessageUpdate {
|
||||
lastMessage: string | null;
|
||||
timestamp: number | null;
|
||||
@@ -13,10 +15,10 @@ export const createLastMessageUpdate = ({
|
||||
lastMessage,
|
||||
lastMessageNotificationText,
|
||||
}: {
|
||||
currentLastMessageText: string | null,
|
||||
currentTimestamp: number | null,
|
||||
lastMessage: Message | null,
|
||||
lastMessageNotificationText: string | null,
|
||||
currentLastMessageText: string | null;
|
||||
currentTimestamp: number | null;
|
||||
lastMessage: Message | null;
|
||||
lastMessageNotificationText: string | null;
|
||||
}): ConversationLastMessageUpdate => {
|
||||
if (lastMessage === null) {
|
||||
return {
|
||||
@@ -30,13 +32,14 @@ export const createLastMessageUpdate = ({
|
||||
const isExpiringMessage = is.object(lastMessage.expirationTimerUpdate);
|
||||
const shouldUpdateTimestamp = !isVerifiedChangeMessage && !isExpiringMessage;
|
||||
|
||||
const newTimestamp = shouldUpdateTimestamp ?
|
||||
lastMessage.sent_at :
|
||||
currentTimestamp;
|
||||
const newTimestamp = shouldUpdateTimestamp
|
||||
? lastMessage.sent_at
|
||||
: currentTimestamp;
|
||||
|
||||
const shouldUpdateLastMessageText = !isVerifiedChangeMessage;
|
||||
const newLastMessageText = shouldUpdateLastMessageText ?
|
||||
lastMessageNotificationText : currentLastMessageText;
|
||||
const newLastMessageText = shouldUpdateLastMessageText
|
||||
? lastMessageNotificationText
|
||||
: currentLastMessageText;
|
||||
|
||||
return {
|
||||
lastMessage: newLastMessageText,
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
export type MIMEType = string & { _mimeTypeBrand: any };
|
||||
|
||||
export const isJPEG = (value: MIMEType): boolean => value === 'image/jpeg';
|
||||
|
||||
export const isJPEG = (value: MIMEType): boolean =>
|
||||
value === 'image/jpeg';
|
||||
export const isImage = (value: MIMEType): boolean => value.startsWith('image/');
|
||||
|
||||
export const isImage = (value: MIMEType): boolean =>
|
||||
value.startsWith('image/');
|
||||
export const isVideo = (value: MIMEType): boolean => value.startsWith('video/');
|
||||
|
||||
export const isVideo = (value: MIMEType): boolean =>
|
||||
value.startsWith('video/');
|
||||
|
||||
export const isAudio = (value: MIMEType): boolean =>
|
||||
value.startsWith('audio/');
|
||||
export const isAudio = (value: MIMEType): boolean => value.startsWith('audio/');
|
||||
|
||||
@@ -1,52 +1,63 @@
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
import { Attachment } from './Attachment';
|
||||
|
||||
export type Message = IncomingMessage | OutgoingMessage | VerifiedChangeMessage;
|
||||
|
||||
export type Message
|
||||
= IncomingMessage
|
||||
| OutgoingMessage
|
||||
| VerifiedChangeMessage;
|
||||
export type IncomingMessage = Readonly<
|
||||
{
|
||||
type: 'incoming';
|
||||
// Required
|
||||
attachments: Array<Attachment>;
|
||||
id: string;
|
||||
received_at: number;
|
||||
|
||||
export type IncomingMessage = Readonly<{
|
||||
type: 'incoming';
|
||||
// Required
|
||||
attachments: Array<Attachment>;
|
||||
id: string;
|
||||
received_at: number;
|
||||
// Optional
|
||||
body?: string;
|
||||
decrypted_at?: number;
|
||||
errors?: Array<any>;
|
||||
flags?: number;
|
||||
source?: string;
|
||||
sourceDevice?: number;
|
||||
} & SharedMessageProperties &
|
||||
Message4 &
|
||||
ExpirationTimerUpdate
|
||||
>;
|
||||
|
||||
// Optional
|
||||
body?: string;
|
||||
decrypted_at?: number;
|
||||
errors?: Array<any>;
|
||||
flags?: number;
|
||||
source?: string;
|
||||
sourceDevice?: number;
|
||||
} & SharedMessageProperties & Message4 & ExpirationTimerUpdate>;
|
||||
export type OutgoingMessage = Readonly<
|
||||
{
|
||||
type: 'outgoing';
|
||||
|
||||
export type OutgoingMessage = Readonly<{
|
||||
type: 'outgoing';
|
||||
// Required
|
||||
attachments: Array<Attachment>;
|
||||
delivered: number;
|
||||
delivered_to: Array<string>;
|
||||
destination: string; // PhoneNumber
|
||||
expirationStartTimestamp: number;
|
||||
id: string;
|
||||
received_at: number;
|
||||
sent: boolean;
|
||||
sent_to: Array<string>; // Array<PhoneNumber>
|
||||
|
||||
// Required
|
||||
attachments: Array<Attachment>;
|
||||
delivered: number;
|
||||
delivered_to: Array<string>;
|
||||
destination: string; // PhoneNumber
|
||||
expirationStartTimestamp: number;
|
||||
id: string;
|
||||
received_at: number;
|
||||
sent: boolean;
|
||||
sent_to: Array<string>; // Array<PhoneNumber>
|
||||
// Optional
|
||||
body?: string;
|
||||
expires_at?: number;
|
||||
expireTimer?: number;
|
||||
recipients?: Array<string>; // Array<PhoneNumber>
|
||||
synced: boolean;
|
||||
} & SharedMessageProperties &
|
||||
Message4 &
|
||||
ExpirationTimerUpdate
|
||||
>;
|
||||
|
||||
// Optional
|
||||
body?: string;
|
||||
expires_at?: number;
|
||||
expireTimer?: number;
|
||||
recipients?: Array<string>; // Array<PhoneNumber>
|
||||
synced: boolean;
|
||||
} & SharedMessageProperties & Message4 & ExpirationTimerUpdate>;
|
||||
|
||||
export type VerifiedChangeMessage = Readonly<{
|
||||
type: 'verified-change';
|
||||
} & SharedMessageProperties & Message4 & ExpirationTimerUpdate>;
|
||||
export type VerifiedChangeMessage = Readonly<
|
||||
{
|
||||
type: 'verified-change';
|
||||
} & SharedMessageProperties &
|
||||
Message4 &
|
||||
ExpirationTimerUpdate
|
||||
>;
|
||||
|
||||
type SharedMessageProperties = Readonly<{
|
||||
conversationId: string;
|
||||
@@ -59,7 +70,7 @@ type ExpirationTimerUpdate = Readonly<{
|
||||
expireTimer: number;
|
||||
fromSync: boolean;
|
||||
source: string; // PhoneNumber
|
||||
}>,
|
||||
}>;
|
||||
}>;
|
||||
|
||||
type Message4 = Readonly<{
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
import { partition } from 'lodash';
|
||||
|
||||
import * as Attachment from '../Attachment';
|
||||
import { Message } from '../message';
|
||||
import { Message } from '../Message';
|
||||
|
||||
export const initializeAttachmentMetadata = async (
|
||||
message: Message
|
||||
): Promise<Message> => {
|
||||
const numAttachments = message.attachments.length;
|
||||
const [numVisualMediaAttachments, numFileAttachments] = partition(
|
||||
message.attachments,
|
||||
Attachment.isVisualMedia
|
||||
).map(attachments => attachments.length);
|
||||
|
||||
export const initializeAttachmentMetadata =
|
||||
async (message: Message): Promise<Message> => {
|
||||
const numAttachments = message.attachments.length;
|
||||
const [numVisualMediaAttachments, numFileAttachments] =
|
||||
partition(message.attachments, Attachment.isVisualMedia)
|
||||
.map((attachments) => attachments.length);
|
||||
|
||||
return {
|
||||
...message,
|
||||
numAttachments,
|
||||
numVisualMediaAttachments,
|
||||
numFileAttachments,
|
||||
};
|
||||
return {
|
||||
...message,
|
||||
numAttachments,
|
||||
numVisualMediaAttachments,
|
||||
numFileAttachments,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user