Remove 25 trivial WhatIsThis types

This commit is contained in:
Evan Hahn 2021-05-03 11:38:20 -05:00 committed by GitHub
parent e5e7e8d392
commit c1730e055f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 34 deletions

View file

@ -7,7 +7,6 @@ import PQueue from 'p-queue';
import dataInterface from './sql/Client'; import dataInterface from './sql/Client';
import { import {
ConversationModelCollectionType, ConversationModelCollectionType,
WhatIsThis,
ConversationAttributesTypeType, ConversationAttributesTypeType,
} from './model-types.d'; } from './model-types.d';
import { SendOptionsType, CallbackResultType } from './textsecure/SendMessage'; import { SendOptionsType, CallbackResultType } from './textsecure/SendMessage';
@ -724,7 +723,7 @@ export class ConversationController {
async prepareForSend( async prepareForSend(
id: string | undefined, id: string | undefined,
options?: WhatIsThis options?: { syncMessage?: boolean; disableMeCheck?: boolean }
): Promise<{ ): Promise<{
wrap: ( wrap: (
promise: Promise<CallbackResultType | void | null> promise: Promise<CallbackResultType | void | null>

View file

@ -157,9 +157,7 @@ export async function startApp(): Promise<void> {
clearSelectedMessage(); clearSelectedMessage();
} }
if (userChanged) { if (userChanged) {
userChanged({ userChanged({ interactionMode });
interactionMode,
} as WhatIsThis);
} }
}; };
window.enterMouseMode = () => { window.enterMouseMode = () => {
@ -175,7 +173,7 @@ export async function startApp(): Promise<void> {
clearSelectedMessage(); clearSelectedMessage();
} }
if (userChanged) { if (userChanged) {
userChanged({ interactionMode } as WhatIsThis); userChanged({ interactionMode });
} }
}; };
@ -195,7 +193,7 @@ export async function startApp(): Promise<void> {
// Load these images now to ensure that they don't flicker on first use // Load these images now to ensure that they don't flicker on first use
window.preloadedImages = []; window.preloadedImages = [];
function preload(list: Array<WhatIsThis>) { function preload(list: ReadonlyArray<string>) {
for (let index = 0, max = list.length; index < max; index += 1) { for (let index = 0, max = list.length; index < max; index += 1) {
const image = new Image(); const image = new Image();
image.src = `./images/${list[index]}`; image.src = `./images/${list[index]}`;
@ -339,7 +337,7 @@ export async function startApp(): Promise<void> {
window.log.info('Storage fetch'); window.log.info('Storage fetch');
window.storage.fetch(); window.storage.fetch();
function mapOldThemeToNew(theme: WhatIsThis) { function mapOldThemeToNew(theme: Readonly<unknown>) {
switch (theme) { switch (theme) {
case 'dark': case 'dark':
case 'light': case 'light':
@ -372,7 +370,7 @@ export async function startApp(): Promise<void> {
'theme-setting', 'theme-setting',
window.platform === 'darwin' ? 'system' : 'light' window.platform === 'darwin' ? 'system' : 'light'
), ),
setThemeSetting: (value: WhatIsThis) => { setThemeSetting: (value: 'light' | 'dark' | 'system') => {
window.storage.put('theme-setting', value); window.storage.put('theme-setting', value);
onChangeTheme(); onChangeTheme();
}, },
@ -1805,7 +1803,7 @@ export async function startApp(): Promise<void> {
USERNAME, USERNAME,
PASSWORD, PASSWORD,
mySignalingKey, mySignalingKey,
messageReceiverOptions as WhatIsThis messageReceiverOptions
); );
window.textsecure.messageReceiver = messageReceiver; window.textsecure.messageReceiver = messageReceiver;
@ -1814,7 +1812,7 @@ export async function startApp(): Promise<void> {
preMessageReceiverStatus = null; preMessageReceiverStatus = null;
// eslint-disable-next-line no-inner-declarations // eslint-disable-next-line no-inner-declarations
function addQueuedEventListener(name: WhatIsThis, handler: WhatIsThis) { function addQueuedEventListener(name: string, handler: WhatIsThis) {
messageReceiver.addEventListener(name, (...args: Array<WhatIsThis>) => messageReceiver.addEventListener(name, (...args: Array<WhatIsThis>) =>
eventHandlerQueue.add(async () => { eventHandlerQueue.add(async () => {
try { try {

4
ts/model-types.d.ts vendored
View file

@ -140,12 +140,12 @@ export type MessageAttributesType = {
attachments: Array<WhatIsThis>; attachments: Array<WhatIsThis>;
preview: Array<WhatIsThis>; preview: Array<WhatIsThis>;
sticker: WhatIsThis; sticker: WhatIsThis;
sent_at: WhatIsThis; sent_at: number;
sent_to: Array<string>; sent_to: Array<string>;
unidentifiedDeliveries: Array<string>; unidentifiedDeliveries: Array<string>;
contact: Array<WhatIsThis>; contact: Array<WhatIsThis>;
conversationId: string; conversationId: string;
recipients: Array<WhatIsThis>; recipients: Array<string>;
reaction: WhatIsThis; reaction: WhatIsThis;
destination?: WhatIsThis; destination?: WhatIsThis;
destinationUuid?: string; destinationUuid?: string;

View file

@ -3547,7 +3547,7 @@ export class ConversationModel extends window.Backbone
} }
async getSendMetadata( async getSendMetadata(
options: { syncMessage?: string; disableMeCheck?: boolean } = {} options: { syncMessage?: boolean; disableMeCheck?: boolean } = {}
): Promise<SendMetadataType | undefined> { ): Promise<SendMetadataType | undefined> {
const { syncMessage, disableMeCheck } = options; const { syncMessage, disableMeCheck } = options;
@ -4227,7 +4227,7 @@ export class ConversationModel extends window.Backbone
async markRead( async markRead(
newestUnreadDate: number, newestUnreadDate: number,
providedOptions: { readAt?: number; sendReadReceipts: boolean } providedOptions: { readAt?: number; sendReadReceipts: boolean }
): Promise<WhatIsThis> { ): Promise<void> {
const options = providedOptions || {}; const options = providedOptions || {};
window._.defaults(options, { sendReadReceipts: true }); window._.defaults(options, { sendReadReceipts: true });
@ -5048,7 +5048,10 @@ export class ConversationModel extends window.Backbone
return `mute(${this.get('id')})`; return `mute(${this.get('id')})`;
} }
async notify(message: WhatIsThis, reaction?: WhatIsThis): Promise<void> { async notify(
message: Readonly<MessageModel>,
reaction?: WhatIsThis
): Promise<void> {
// As a performance optimization don't perform any work if notifications are // As a performance optimization don't perform any work if notifications are
// disabled. // disabled.
if (!window.Whisper.Notifications.isEnabled) { if (!window.Whisper.Notifications.isEnabled) {
@ -5296,7 +5299,7 @@ window.Whisper.ConversationCollection = window.Backbone.Collection.extend({
this.generateLookups(this.models); this.generateLookups(this.models);
}, },
generateLookups(models: Array<WhatIsThis>) { generateLookups(models: ReadonlyArray<ConversationModel>) {
models.forEach(model => { models.forEach(model => {
const e164 = model.get('e164'); const e164 = model.get('e164');
if (e164) { if (e164) {

View file

@ -3541,9 +3541,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
// GroupV1 // GroupV1
if (!isGroupV2 && dataMessage.group) { if (!isGroupV2 && dataMessage.group) {
const pendingGroupUpdate = []; const pendingGroupUpdate = [];
const memberConversations: Array< const memberConversations: Array<ConversationModel> = await Promise.all(
typeof window.WhatIsThis
> = await Promise.all(
dataMessage.group.membersE164.map((e164: string) => dataMessage.group.membersE164.map((e164: string) =>
window.ConversationController.getOrCreateAndWait( window.ConversationController.getOrCreateAndWait(
e164, e164,
@ -3815,10 +3813,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
}); });
} }
window.MessageController.register( window.MessageController.register(message.id, message);
message.id,
message as typeof window.WhatIsThis
);
conversation.incrementMessageCount(); conversation.incrementMessageCount();
window.Signal.Data.updateConversation(conversation.attributes); window.Signal.Data.updateConversation(conversation.attributes);
@ -4102,7 +4097,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
} }
} }
window.Whisper.Message = MessageModel as typeof window.WhatIsThis; window.Whisper.Message = MessageModel;
window.Whisper.Message.getLongMessageAttachment = ({ window.Whisper.Message.getLongMessageAttachment = ({
body, body,
@ -4137,7 +4132,7 @@ window.Whisper.Message.updateTimers = () => {
window.Whisper.MessageCollection = window.Backbone.Collection.extend({ window.Whisper.MessageCollection = window.Backbone.Collection.extend({
model: window.Whisper.Message, model: window.Whisper.Message,
comparator(left: typeof window.WhatIsThis, right: typeof window.WhatIsThis) { comparator(left: Readonly<MessageModel>, right: Readonly<MessageModel>) {
if (left.get('received_at') === right.get('received_at')) { if (left.get('received_at') === right.get('received_at')) {
return (left.get('sent_at') || 0) - (right.get('sent_at') || 0); return (left.get('sent_at') || 0) - (right.get('sent_at') || 0);
} }

2
ts/textsecure.d.ts vendored
View file

@ -85,7 +85,7 @@ export type TextSecureType = {
EventTarget: typeof EventTarget; EventTarget: typeof EventTarget;
MessageReceiver: typeof MessageReceiver; MessageReceiver: typeof MessageReceiver;
AccountManager: WhatIsThis; AccountManager: WhatIsThis;
MessageSender: WhatIsThis; MessageSender: typeof MessageSender;
SyncRequest: typeof SyncRequest; SyncRequest: typeof SyncRequest;
}; };

11
ts/window.d.ts vendored
View file

@ -150,7 +150,7 @@ declare global {
enterMouseMode: () => void; enterMouseMode: () => void;
getAccountManager: () => AccountManager | undefined; getAccountManager: () => AccountManager | undefined;
getAlwaysRelayCalls: () => Promise<boolean>; getAlwaysRelayCalls: () => Promise<boolean>;
getBuiltInImages: () => Promise<Array<WhatIsThis>>; getBuiltInImages: () => Promise<Array<string>>;
getCallRingtoneNotification: () => Promise<boolean>; getCallRingtoneNotification: () => Promise<boolean>;
getCallSystemNotification: () => Promise<boolean>; getCallSystemNotification: () => Promise<boolean>;
getConversations: () => ConversationModelCollectionType; getConversations: () => ConversationModelCollectionType;
@ -175,8 +175,8 @@ declare global {
showCallingPermissionsPopup: (forCamera: boolean) => Promise<void>; showCallingPermissionsPopup: (forCamera: boolean) => Promise<void>;
i18n: LocalizerType; i18n: LocalizerType;
isActive: () => boolean; isActive: () => boolean;
isAfterVersion: (version: WhatIsThis, anotherVersion: string) => boolean; isAfterVersion: (version: string, anotherVersion: string) => boolean;
isBeforeVersion: (version: WhatIsThis, anotherVersion: string) => boolean; isBeforeVersion: (version: string, anotherVersion: string) => boolean;
isFullScreen: () => boolean; isFullScreen: () => boolean;
isValidGuid: (maybeGuid: string | null) => boolean; isValidGuid: (maybeGuid: string | null) => boolean;
isValidE164: (maybeE164: unknown) => boolean; isValidE164: (maybeE164: unknown) => boolean;
@ -328,10 +328,7 @@ declare global {
stickerId: number stickerId: number
) => Promise<typeof window.Signal.Types.Sticker>; ) => Promise<typeof window.Signal.Types.Sticker>;
deletePackReference: (id: string, packId: string) => Promise<void>; deletePackReference: (id: string, packId: string) => Promise<void>;
downloadEphemeralPack: ( downloadEphemeralPack: (packId: string, key: string) => Promise<void>;
packId: string,
key: WhatIsThis
) => Promise<void>;
downloadQueuedPacks: () => void; downloadQueuedPacks: () => void;
downloadStickerPack: ( downloadStickerPack: (
id: string, id: string,