From c956c0e0254bb56e8773d0e2002461e808a46586 Mon Sep 17 00:00:00 2001 From: Jamie Kyle <113370520+jamiebuilds-signal@users.noreply.github.com> Date: Mon, 10 Apr 2023 14:30:33 -0700 Subject: [PATCH] Remove ts/util/index.ts --- ts/components/conversation/MessageDetail.tsx | 2 +- ts/signal.ts | 45 ++++++++++- ts/state/selectors/search.ts | 2 +- ts/test-electron/services/profiles_test.ts | 2 +- ts/util/index.ts | 78 -------------------- ts/window.d.ts | 52 +++++++++++-- 6 files changed, 93 insertions(+), 88 deletions(-) delete mode 100644 ts/util/index.ts diff --git a/ts/components/conversation/MessageDetail.tsx b/ts/components/conversation/MessageDetail.tsx index 7efa3a1069..4adb18115b 100644 --- a/ts/components/conversation/MessageDetail.tsx +++ b/ts/components/conversation/MessageDetail.tsx @@ -26,7 +26,7 @@ import * as log from '../../logging/log'; import { formatDateTimeLong } from '../../util/timestamp'; import { DurationInSeconds } from '../../util/durations'; import { format as formatRelativeTime } from '../../util/expirationTimer'; -import { missingCaseError } from '../../util'; +import { missingCaseError } from '../../util/missingCaseError'; export type Contact = Pick< ConversationType, diff --git a/ts/signal.ts b/ts/signal.ts index 7cfb19a1be..2f2f8c25ef 100644 --- a/ts/signal.ts +++ b/ts/signal.ts @@ -10,7 +10,9 @@ import Data from './sql/Client'; import * as Groups from './groups'; import * as OS from './OS'; import * as RemoteConfig from './RemoteConfig'; -import * as Util from './util'; +import * as GoogleChrome from './util/GoogleChrome'; +import * as Registration from './util/registration'; +import * as zkgroup from './util/zkgroup'; // Components import { ConfirmationDialog } from './components/ConfirmationDialog'; @@ -47,6 +49,25 @@ import type { EmbeddedContactType } from './types/EmbeddedContact'; import type { ContactWithHydratedAvatar } from './textsecure/SendMessage'; import type { LinkPreviewType } from './types/message/LinkPreviews'; import type { StickerType, StickerWithHydratedData } from './types/Stickers'; +import { MessageController } from './util/MessageController'; +import { + flushMessageCounter, + incrementMessageCounter, + initializeMessageCounter, +} from './util/incrementMessageCounter'; +import { sleep } from './util/sleep'; +import { + queueUpdateMessage, + saveNewMessageBatcher, + setBatchingStrategy, +} from './util/messageBatcher'; +import { sendContentMessageToGroup, sendToGroup } from './util/sendToGroup'; +import { makeLookup } from './util/makeLookup'; +import { getStringForProfileChange } from './util/getStringForProfileChange'; +import { deleteForEveryone } from './util/deleteForEveryone'; +import { RetryPlaceholders } from './util/retryPlaceholders'; +import { parseRemoteClientExpiration } from './util/parseRemoteClientExpiration'; +import { createBatcher } from './util/batcher'; type MigrationsModuleType = { attachmentsPath: string; @@ -401,6 +422,26 @@ export const setup = (options: { Services, State, Types, - Util, + Util: { + createBatcher, + deleteForEveryone, + flushMessageCounter, + getStringForProfileChange, + GoogleChrome, + incrementMessageCounter, + initializeMessageCounter, + makeLookup, + MessageController, + parseRemoteClientExpiration, + queueUpdateMessage, + Registration, + RetryPlaceholders, + saveNewMessageBatcher, + sendContentMessageToGroup, + sendToGroup, + setBatchingStrategy, + sleep, + zkgroup, + }, }; }; diff --git a/ts/state/selectors/search.ts b/ts/state/selectors/search.ts index b83faafd07..890a35f8fa 100644 --- a/ts/state/selectors/search.ts +++ b/ts/state/selectors/search.ts @@ -32,7 +32,7 @@ import type { HydratedBodyRangeType } from '../../types/BodyRange'; import { BodyRange } from '../../types/BodyRange'; import * as log from '../../logging/log'; import { getOwn } from '../../util/getOwn'; -import { missingCaseError } from '../../util'; +import { missingCaseError } from '../../util/missingCaseError'; export const getSearch = (state: StateType): SearchStateType => state.search; diff --git a/ts/test-electron/services/profiles_test.ts b/ts/test-electron/services/profiles_test.ts index de74db1a89..94437c5315 100644 --- a/ts/test-electron/services/profiles_test.ts +++ b/ts/test-electron/services/profiles_test.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: AGPL-3.0-only import { assert } from 'chai'; -import { sleep } from '../../util'; +import { sleep } from '../../util/sleep'; import { MINUTE } from '../../util/durations'; import { drop } from '../../util/drop'; diff --git a/ts/util/index.ts b/ts/util/index.ts deleted file mode 100644 index ee2f94986d..0000000000 --- a/ts/util/index.ts +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2018 Signal Messenger, LLC -// SPDX-License-Identifier: AGPL-3.0-only - -import * as GoogleChrome from './GoogleChrome'; -import * as Registration from './registration'; -import { arrayBufferToObjectURL } from './arrayBufferToObjectURL'; -import { combineNames } from './combineNames'; -import { createBatcher } from './batcher'; -import { createWaitBatcher } from './waitBatcher'; -import { deleteForEveryone } from './deleteForEveryone'; -import { downloadAttachment } from './downloadAttachment'; -import { getStringForProfileChange } from './getStringForProfileChange'; -import { getUuidsForE164s } from './getUuidsForE164s'; -import { getUserAgent } from './getUserAgent'; -import { - initializeMessageCounter, - incrementMessageCounter, - flushMessageCounter, -} from './incrementMessageCounter'; -import { isFileDangerous } from './isFileDangerous'; -import { makeLookup } from './makeLookup'; -import { - queueUpdateMessage, - saveNewMessageBatcher, - setBatchingStrategy, -} from './messageBatcher'; -import { missingCaseError } from './missingCaseError'; -import { parseRemoteClientExpiration } from './parseRemoteClientExpiration'; -import { sleep } from './sleep'; -import { longRunningTaskWrapper } from './longRunningTaskWrapper'; -import { toWebSafeBase64, fromWebSafeBase64 } from './webSafeBase64'; -import { mapToSupportLocale } from './mapToSupportLocale'; -import { - sessionRecordToProtobuf, - sessionStructureToBytes, -} from './sessionTranslation'; -import * as zkgroup from './zkgroup'; -import { sendToGroup, sendContentMessageToGroup } from './sendToGroup'; -import { RetryPlaceholders } from './retryPlaceholders'; -import * as expirationTimer from './expirationTimer'; -import { MessageController } from './MessageController'; - -export { - GoogleChrome, - Registration, - arrayBufferToObjectURL, - combineNames, - createBatcher, - createWaitBatcher, - deleteForEveryone, - downloadAttachment, - flushMessageCounter, - fromWebSafeBase64, - getStringForProfileChange, - getUserAgent, - incrementMessageCounter, - initializeMessageCounter, - isFileDangerous, - longRunningTaskWrapper, - makeLookup, - mapToSupportLocale, - MessageController, - missingCaseError, - parseRemoteClientExpiration, - queueUpdateMessage, - RetryPlaceholders, - saveNewMessageBatcher, - sendContentMessageToGroup, - sendToGroup, - setBatchingStrategy, - sessionRecordToProtobuf, - sessionStructureToBytes, - sleep, - toWebSafeBase64, - zkgroup, - expirationTimer, - getUuidsForE164s, -}; diff --git a/ts/window.d.ts b/ts/window.d.ts index ec0bf80d6e..eb85703fa0 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -8,9 +8,10 @@ import type { Store } from 'redux'; import type * as Backbone from 'backbone'; import type PQueue from 'p-queue/dist'; import type { assert } from 'chai'; - import type { PhoneNumber, PhoneNumberFormat } from 'google-libphonenumber'; -import type * as Util from './util'; +import type * as Registration from './util/registration'; +import type * as zkgroup from './util/zkgroup'; + import type { ConversationModelCollectionType, MessageModelCollectionType, @@ -40,7 +41,7 @@ import type { createApp } from './state/roots/createApp'; import type Data from './sql/Client'; import type { MessageModel } from './models/messages'; import type { ConversationModel } from './models/conversations'; -import type { BatcherType } from './util/batcher'; +import type { BatcherType, createBatcher } from './util/batcher'; import type { ConfirmationDialog } from './components/ConfirmationDialog'; import type { SignalProtocolStore } from './SignalProtocolStore'; import type { SocketStatus } from './types/SocketStatus'; @@ -56,6 +57,27 @@ import type { IPCEventsType } from './util/createIPCEvents'; import type { SignalContextType } from './windows/context'; import type * as Message2 from './types/Message2'; import type { initializeMigrations } from './signal'; +import type { + flushMessageCounter, + incrementMessageCounter, + initializeMessageCounter, +} from './util/incrementMessageCounter'; +import type { RetryPlaceholders } from './util/retryPlaceholders'; +import type { sleep } from './util/sleep'; +import type { + queueUpdateMessage, + saveNewMessageBatcher, + setBatchingStrategy, +} from './util/messageBatcher'; +import type { + sendContentMessageToGroup, + sendToGroup, +} from './util/sendToGroup'; +import type * as GoogleChrome from './util/GoogleChrome'; +import type { makeLookup } from './util/makeLookup'; +import type { getStringForProfileChange } from './util/getStringForProfileChange'; +import type { deleteForEveryone } from './util/deleteForEveryone'; +import type { parseRemoteClientExpiration } from './util/parseRemoteClientExpiration'; export { Long } from 'long'; @@ -122,7 +144,7 @@ export type SignalCoreType = { initializeGroupCredentialFetcher: () => Promise; initializeNetworkObserver: (network: ReduxActions['network']) => void; initializeUpdateListener: (updates: ReduxActions['updates']) => void; - retryPlaceholders?: Util.RetryPlaceholders; + retryPlaceholders?: RetryPlaceholders; lightSessionResetQueue?: PQueue; storage: typeof StorageService; }; @@ -133,7 +155,27 @@ export type SignalCoreType = { Address: typeof Address; QualifiedAddress: typeof QualifiedAddress; }; - Util: typeof Util; + Util: { + createBatcher: typeof createBatcher; + deleteForEveryone: typeof deleteForEveryone; + flushMessageCounter: typeof flushMessageCounter; + getStringForProfileChange: typeof getStringForProfileChange; + GoogleChrome: typeof GoogleChrome; + incrementMessageCounter: typeof incrementMessageCounter; + initializeMessageCounter: typeof initializeMessageCounter; + makeLookup: typeof makeLookup; + MessageController: typeof MessageController; + parseRemoteClientExpiration: typeof parseRemoteClientExpiration; + queueUpdateMessage: typeof queueUpdateMessage; + Registration: typeof Registration; + RetryPlaceholders: typeof RetryPlaceholders; + saveNewMessageBatcher: typeof saveNewMessageBatcher; + sendContentMessageToGroup: typeof sendContentMessageToGroup; + sendToGroup: typeof sendToGroup; + setBatchingStrategy: typeof setBatchingStrategy; + sleep: typeof sleep; + zkgroup: typeof zkgroup; + }; Components: { ConfirmationDialog: typeof ConfirmationDialog; };