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

View File

@ -157,9 +157,7 @@ export async function startApp(): Promise<void> {
clearSelectedMessage();
}
if (userChanged) {
userChanged({
interactionMode,
} as WhatIsThis);
userChanged({ interactionMode });
}
};
window.enterMouseMode = () => {
@ -175,7 +173,7 @@ export async function startApp(): Promise<void> {
clearSelectedMessage();
}
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
window.preloadedImages = [];
function preload(list: Array<WhatIsThis>) {
function preload(list: ReadonlyArray<string>) {
for (let index = 0, max = list.length; index < max; index += 1) {
const image = new Image();
image.src = `./images/${list[index]}`;
@ -339,7 +337,7 @@ export async function startApp(): Promise<void> {
window.log.info('Storage fetch');
window.storage.fetch();
function mapOldThemeToNew(theme: WhatIsThis) {
function mapOldThemeToNew(theme: Readonly<unknown>) {
switch (theme) {
case 'dark':
case 'light':
@ -372,7 +370,7 @@ export async function startApp(): Promise<void> {
'theme-setting',
window.platform === 'darwin' ? 'system' : 'light'
),
setThemeSetting: (value: WhatIsThis) => {
setThemeSetting: (value: 'light' | 'dark' | 'system') => {
window.storage.put('theme-setting', value);
onChangeTheme();
},
@ -1805,7 +1803,7 @@ export async function startApp(): Promise<void> {
USERNAME,
PASSWORD,
mySignalingKey,
messageReceiverOptions as WhatIsThis
messageReceiverOptions
);
window.textsecure.messageReceiver = messageReceiver;
@ -1814,7 +1812,7 @@ export async function startApp(): Promise<void> {
preMessageReceiverStatus = null;
// 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>) =>
eventHandlerQueue.add(async () => {
try {

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

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

View File

@ -3547,7 +3547,7 @@ export class ConversationModel extends window.Backbone
}
async getSendMetadata(
options: { syncMessage?: string; disableMeCheck?: boolean } = {}
options: { syncMessage?: boolean; disableMeCheck?: boolean } = {}
): Promise<SendMetadataType | undefined> {
const { syncMessage, disableMeCheck } = options;
@ -4227,7 +4227,7 @@ export class ConversationModel extends window.Backbone
async markRead(
newestUnreadDate: number,
providedOptions: { readAt?: number; sendReadReceipts: boolean }
): Promise<WhatIsThis> {
): Promise<void> {
const options = providedOptions || {};
window._.defaults(options, { sendReadReceipts: true });
@ -5048,7 +5048,10 @@ export class ConversationModel extends window.Backbone
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
// disabled.
if (!window.Whisper.Notifications.isEnabled) {
@ -5296,7 +5299,7 @@ window.Whisper.ConversationCollection = window.Backbone.Collection.extend({
this.generateLookups(this.models);
},
generateLookups(models: Array<WhatIsThis>) {
generateLookups(models: ReadonlyArray<ConversationModel>) {
models.forEach(model => {
const e164 = model.get('e164');
if (e164) {

View File

@ -3541,9 +3541,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
// GroupV1
if (!isGroupV2 && dataMessage.group) {
const pendingGroupUpdate = [];
const memberConversations: Array<
typeof window.WhatIsThis
> = await Promise.all(
const memberConversations: Array<ConversationModel> = await Promise.all(
dataMessage.group.membersE164.map((e164: string) =>
window.ConversationController.getOrCreateAndWait(
e164,
@ -3815,10 +3813,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
});
}
window.MessageController.register(
message.id,
message as typeof window.WhatIsThis
);
window.MessageController.register(message.id, message);
conversation.incrementMessageCount();
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 = ({
body,
@ -4137,7 +4132,7 @@ window.Whisper.Message.updateTimers = () => {
window.Whisper.MessageCollection = window.Backbone.Collection.extend({
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')) {
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;
MessageReceiver: typeof MessageReceiver;
AccountManager: WhatIsThis;
MessageSender: WhatIsThis;
MessageSender: typeof MessageSender;
SyncRequest: typeof SyncRequest;
};

11
ts/window.d.ts vendored
View File

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