Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ts/Crypto.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,14 +431,12 @@ export function decryptAesCtr(
function encryptAesGcm(
key: Uint8Array<ArrayBuffer>,
iv: Uint8Array<ArrayBuffer>,
plaintext: Uint8Array<ArrayBuffer>,
aad?: Uint8Array<ArrayBuffer>
plaintext: Uint8Array<ArrayBuffer>
): Uint8Array<ArrayBuffer> {
return encrypt(CipherType.AES256GCM, {
key,
plaintext,
iv,
aad,
});
}

Expand Down
9 changes: 2 additions & 7 deletions ts/axo/_internal/AxoMath.dom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ export namespace AxoMath {
}

/** Works the same way as CSS `progress([no-clamp] <min> <value> <max>)` */
export function progress(
value: number,
min: number,
max: number,
noClamp?: boolean
): number {
export function progress(value: number, min: number, max: number): number {
assert(max > min, 'max must be greater than min');
const result = (value - min) / (max - min);
return noClamp ? result : clamp(result, 0, 1);
return clamp(result, 0, 1);
}

export function circumference(radius: number): number {
Expand Down
3 changes: 0 additions & 3 deletions ts/components/Button.dom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export type PropsType = {
size?: ButtonSize;
style?: CSSProperties;
tabIndex?: number;
testId?: string;
theme?: Theme;
variant?: ButtonVariant;
'aria-disabled'?: boolean;
Expand Down Expand Up @@ -98,7 +97,6 @@ export const Button = forwardRef<HTMLButtonElement, PropsType>(
discouraged = false,
style,
tabIndex,
testId,
theme,
variant = ButtonVariant.Primary,
size = ButtonSize.Medium,
Expand Down Expand Up @@ -136,7 +134,6 @@ export const Button = forwardRef<HTMLButtonElement, PropsType>(
className,
className && discouraged ? `${className}--discouraged` : undefined
)}
data-testid={testId}
disabled={disabled}
onClick={onClick}
form={form}
Expand Down
1 change: 0 additions & 1 deletion ts/components/CallParticipantCount.dom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export type PropsType = {
callMode: CallMode.Group | CallMode.Adhoc;
i18n: LocalizerType;
isAdhocJoinRequestPending?: boolean;
groupMemberCount?: number;
participantCount: number;
toggleParticipants: () => void;
};
Expand Down
6 changes: 2 additions & 4 deletions ts/components/GroupMembersNames.dom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const { take } = lodash;

type PropsType = {
i18n: LocalizerType;
nameClassName?: string;
memberships: ReadonlyArray<GroupV2Membership>;
invitesCount?: number;
onOtherMembersClick?: () => void;
Expand Down Expand Up @@ -170,7 +169,6 @@ function MemberList({

export function GroupMembersNames({
i18n,
nameClassName,
memberships,
invitesCount,
onOtherMembersClick,
Expand Down Expand Up @@ -203,11 +201,11 @@ export function GroupMembersNames({
).map((name, i) => (
// We cannot guarantee uniqueness of member names
// oxlint-disable-next-line react/no-array-index-key
<span key={i} className={nameClassName}>
<span key={i}>
<UserText text={name ?? i18n('icu:unknownContactShort')} />
</span>
));
}, [otherMemberNames, nameClassName, i18n]);
}, [otherMemberNames, i18n]);

const memberListElement = (
<MemberList
Expand Down
4 changes: 1 addition & 3 deletions ts/components/SharedGroupNames.dom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@ const { take } = lodash;

type PropsType = {
i18n: LocalizerType;
nameClassName?: string;
sharedGroupNames: ReadonlyArray<string>;
};

export function SharedGroupNames({
i18n,
nameClassName,
sharedGroupNames,
}: PropsType): JSX.Element {
const firstThreeGroups = take(sharedGroupNames, 3).map((group, i) => (
// We cannot guarantee uniqueness of group names
// oxlint-disable-next-line react/no-array-index-key
<strong key={i} className={nameClassName}>
<strong key={i}>
<UserText text={group} />
</strong>
));
Expand Down
3 changes: 1 addition & 2 deletions ts/components/StoryViewsNRepliesModal.dom.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

import type { ReactNode, JSX, RefObject, MouseEvent } from 'react';
import type { ReactNode, JSX, RefObject } from 'react';
import { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
import classNames from 'classnames';
import lodash from 'lodash';
Expand Down Expand Up @@ -546,7 +546,6 @@ type ReplyOrReactionMessageProps = {
id: string;
isInternalUser?: boolean;
isSpoilerExpanded: Record<number, boolean>;
onContextMenu?: (ev: MouseEvent) => void;
reply: ReplyType;
shouldCollapseAbove: boolean;
shouldCollapseBelow: boolean;
Expand Down
11 changes: 3 additions & 8 deletions ts/components/conversation/ContactName.dom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export type ContactNameData = {
};

export function useContactNameData(
conversation: ConversationType | null,
contactNameColor?: ContactNameColorType
conversation: ConversationType | null
): ContactNameData | null {
const { firstName, title, isMe } = conversation ?? {};
const isSignalConversation =
Expand All @@ -40,17 +39,15 @@ export function useContactNameData(
return null;
}
return {
contactNameColor,
firstName,
isSignalConversation,
isMe,
title,
};
}, [contactNameColor, firstName, isSignalConversation, isMe, title]);
}, [firstName, isSignalConversation, isMe, title]);
}

export type PropsType = ContactNameData & {
fontSizeOverride?: number;
module?: string;
preferFirstName?: boolean;
onClick?: VoidFunction;
Expand Down Expand Up @@ -121,15 +118,13 @@ export function GroupMemberLabel({
contactLabel,
contactNameColor,
context,
module,
}: {
emojiSize?: FunStaticEmojiSize;
contactLabel?: MemberLabelType;
contactNameColor?: ContactNameColorType;
context: Context;
module?: string;
}): ReactNode {
const getClassName = getClassNamesFor('module-contact-name', module);
const getClassName = getClassNamesFor('module-contact-name');

if (!contactLabel) {
return null;
Expand Down
15 changes: 5 additions & 10 deletions ts/messages/copyQuote.preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,11 @@ export type MinimalMessageCache = Readonly<{
register: (message: MessageModel) => MessageModel;
}>;

export type CopyQuoteOptionsType = Readonly<{
messageCache?: MinimalMessageCache;
}>;

export const copyFromQuotedMessage = async (
quote: ProcessedQuote,
conversationId: string,
options: CopyQuoteOptionsType = {}
conversationId: string
): Promise<QuotedMessageType> => {
const { messageCache = window.MessageCache } = options;
const messageCache = window.MessageCache;
const { id } = quote;
strictAssert(id, 'Quote must have an id');

Expand Down Expand Up @@ -80,17 +75,17 @@ export const copyFromQuotedMessage = async (
}

if (queryMessage) {
await copyQuoteContentFromOriginal(queryMessage, result, options);
await copyQuoteContentFromOriginal(queryMessage, result);
}

return result;
};

export const copyQuoteContentFromOriginal = async (
message: MessageModel,
quote: QuotedMessageType,
{ messageCache = window.MessageCache }: CopyQuoteOptionsType = {}
quote: QuotedMessageType
): Promise<void> => {
const messageCache = window.MessageCache;
const { attachments } = quote;
const quoteAttachment = attachments ? attachments[0] : undefined;

Expand Down
16 changes: 6 additions & 10 deletions ts/models/conversations.preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import { hasDraft } from '../util/hasDraft.std.ts';
import { getStoryReplyContext } from '../util/getStoryReplyContext.std.ts';
import { normalizeProfileName } from '../util/normalizeProfileName.std.ts';
import type {
StickerType,
StickerWithHydratedData,
} from '../types/Stickers.preload.ts';
import * as Stickers from '../types/Stickers.preload.ts';
Expand Down Expand Up @@ -4017,11 +4016,9 @@ export class ConversationModel {
}

// TODO(DESKTOP-9497): This will not include `ourAci` in 1:1 chats
getMembers(
options: { includePendingMembers?: boolean } = {}
): Array<ConversationModel> {
getMembers(): Array<ConversationModel> {
return compact(
getConversationMembers(this.attributes, options).map(conversationAttrs =>
getConversationMembers(this.attributes).map(conversationAttrs =>
window.ConversationController.get(conversationAttrs.id)
)
);
Expand Down Expand Up @@ -4061,16 +4058,15 @@ export class ConversationModel {

async getQuoteAttachment(
attachments?: Array<AttachmentType>,
preview?: Array<LinkPreviewType>,
sticker?: StickerType
preview?: Array<LinkPreviewType>
): Promise<
Array<{
contentType: MIMEType;
fileName?: string | null;
thumbnail?: ThumbnailType | null;
}>
> {
return getQuoteAttachment(attachments, preview, sticker);
return getQuoteAttachment(attachments, preview);
}

async sendStickerMessage(
Expand Down Expand Up @@ -5672,8 +5668,8 @@ export class ConversationModel {
log.info(`${logId}: Delete complete`);
}

getTitle(options?: { isShort?: boolean }): string {
return getTitle(this.attributes, options);
getTitle(): string {
return getTitle(this.attributes);
}

getTitleNoDefault(options?: { isShort?: boolean }): string | undefined {
Expand Down
5 changes: 2 additions & 3 deletions ts/util/canvasToBytes.std.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import type { MIMEType } from '../types/MIME.std.ts';

export async function canvasToBytes(
canvas: HTMLCanvasElement,
mimeType?: MIMEType,
quality?: number
mimeType?: MIMEType
): Promise<Uint8Array<ArrayBuffer>> {
const blob = await canvasToBlob(canvas, mimeType, quality);
const blob = await canvasToBlob(canvas, mimeType);
return new Uint8Array(await blob.arrayBuffer());
}
31 changes: 2 additions & 29 deletions ts/util/generateDonationReceipt.dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,14 @@ const COLORS = {
* NOTE: letterSpacing does not work for arabic, breaks the script
* @param params - Object containing original values to scale
* @param params.fontSize - Original font size in pixels
* @param params.height - Optional original height/margin/padding in pixels
* @param params.letterSpacing - Optional original letter spacing in pixels
* @returns Scaled values for use in FabricJS
*/
function scaleValues(params: {
function scaleValues(params: { fontSize: number }): {
fontSize: number;
height?: number;
letterSpacing?: number;
}): {
fontSize: number;
height?: number;
charSpacing?: number;
} {
const result: {
fontSize: number;
height?: number;
charSpacing?: number;
} = {
return {
fontSize: params.fontSize * SCALING_FACTOR,
};

if (params.height !== undefined) {
result.height = params.height * SCALING_FACTOR;
}

if (params.letterSpacing !== undefined) {
// FabricJS charSpacing is in thousandths of em units
// Formula: (letterSpacingPx * 1000) / fontSizePx
// This converts pixel-based letter spacing to em-based units
// For example: -0.13px letter spacing on 12px font =
// (-0.13 * 1000) / 12 = -10.83 thousandths of em
result.charSpacing = (params.letterSpacing * 1000) / params.fontSize;
}

return result;
}

const SIGNAL_LOGO_SVG = `<svg width="417" height="121" viewBox="0 0 560 160" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down
5 changes: 1 addition & 4 deletions ts/util/getTestMegaphone.std.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import { DAY } from './durations/index.std.ts';
const INTERNAL_TEST_ID = 'INTERNAL_TEST' as RemoteMegaphoneId;
export const TEST_MEGAPHONE_IMAGE = 'images/donate-heart.png';

export function internalGetTestMegaphone(
props?: Partial<VisibleRemoteMegaphoneType>
): VisibleRemoteMegaphoneType {
export function internalGetTestMegaphone(): VisibleRemoteMegaphoneType {
return {
priority: 100,
desktopMinVersion: '1.0.0',
Expand All @@ -35,7 +33,6 @@ export function internalGetTestMegaphone(
snoozedAt: null,
shownAt: null,
isFinished: false,
...props,
id: INTERNAL_TEST_ID,
};
}
Expand Down
8 changes: 1 addition & 7 deletions ts/util/numbers.std.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,11 @@ export function safeParseNumber(value: number | string): number | null {
return parsed;
}

export function safeParseInteger(
value: number | string,
trunc = false
): number | null {
export function safeParseInteger(value: number | string): number | null {
const parsed = safeParseNumber(value);
if (parsed == null) {
return null;
}
if (trunc) {
return Math.trunc(parsed);
}
if (!Number.isInteger(parsed)) {
return null;
}
Expand Down
Loading