| 
									
										
										
										
											2023-01-03 11:55:46 -08:00
										 |  |  | // Copyright 2020 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-22 12:27:49 -08:00
										 |  |  | import { ipcRenderer } from 'electron'; | 
					
						
							| 
									
										
										
										
											2023-01-09 10:38:57 -08:00
										 |  |  | import type { AudioDevice } from '@signalapp/ringrtc'; | 
					
						
							| 
									
										
										
										
											2022-10-18 10:12:02 -07:00
										 |  |  | import { noop } from 'lodash'; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { ZoomFactorType } from '../types/Storage.d'; | 
					
						
							|  |  |  | import type { | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   ConversationColorType, | 
					
						
							|  |  |  |   CustomColorType, | 
					
						
							|  |  |  |   DefaultConversationColorType, | 
					
						
							|  |  |  | } from '../types/Colors'; | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import { DEFAULT_CONVERSATION_COLOR } from '../types/Colors'; | 
					
						
							| 
									
										
										
										
											2022-11-22 10:43:43 -08:00
										 |  |  | import * as Errors from '../types/errors'; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | import * as Stickers from '../types/Stickers'; | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { SystemTraySetting } from '../types/SystemTraySetting'; | 
					
						
							|  |  |  | import { parseSystemTraySetting } from '../types/SystemTraySetting'; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { ConversationType } from '../state/ducks/conversations'; | 
					
						
							| 
									
										
										
										
											2023-02-27 14:34:43 -08:00
										 |  |  | import type { AuthorizeArtCreatorDataType } from '../state/ducks/globalModals'; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | import { calling } from '../services/calling'; | 
					
						
							| 
									
										
										
										
											2023-07-20 05:14:08 +02:00
										 |  |  | import { resolveUsernameByLinkBase64 } from '../services/username'; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | import { getConversationsWithCustomColorSelector } from '../state/selectors/conversations'; | 
					
						
							|  |  |  | import { getCustomColors } from '../state/selectors/items'; | 
					
						
							|  |  |  | import { themeChanged } from '../shims/themeChanged'; | 
					
						
							| 
									
										
										
										
											2021-08-24 16:57:34 -04:00
										 |  |  | import { renderClearingDataView } from '../shims/renderClearingDataView'; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | import * as universalExpireTimer from './universalExpireTimer'; | 
					
						
							|  |  |  | import { PhoneNumberDiscoverability } from './phoneNumberDiscoverability'; | 
					
						
							|  |  |  | import { PhoneNumberSharingMode } from './phoneNumberSharingMode'; | 
					
						
							| 
									
										
										
										
											2023-02-23 13:32:19 -08:00
										 |  |  | import { strictAssert, assertDev } from './assert'; | 
					
						
							| 
									
										
										
										
											2021-08-26 09:10:58 -05:00
										 |  |  | import * as durations from './durations'; | 
					
						
							| 
									
										
										
										
											2022-11-16 12:18:02 -08:00
										 |  |  | import type { DurationInSeconds } from './durations'; | 
					
						
							| 
									
										
										
										
											2021-08-18 21:04:38 -04:00
										 |  |  | import { isPhoneNumberSharingEnabled } from './isPhoneNumberSharingEnabled'; | 
					
						
							| 
									
										
										
										
											2023-04-10 20:54:43 -07:00
										 |  |  | import * as Registration from './registration'; | 
					
						
							| 
									
										
										
										
											2023-08-10 18:43:33 +02:00
										 |  |  | import { lookupConversationWithoutServiceId } from './lookupConversationWithoutServiceId'; | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  | import * as log from '../logging/log'; | 
					
						
							| 
									
										
										
										
											2022-10-19 12:35:56 -04:00
										 |  |  | import { deleteAllMyStories } from './deleteAllMyStories'; | 
					
						
							| 
									
										
										
										
											2023-08-01 09:06:29 -07:00
										 |  |  | import type { NotificationClickData } from '../services/notifications'; | 
					
						
							|  |  |  | import { StoryViewModeType, StoryViewTargetType } from '../types/Stories'; | 
					
						
							| 
									
										
										
										
											2023-11-02 12:42:31 -07:00
										 |  |  | import { isValidE164 } from './isValidE164'; | 
					
						
							|  |  |  | import { fromWebSafeBase64 } from './webSafeBase64'; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-02 18:54:37 -05:00
										 |  |  | type SentMediaQualityType = 'standard' | 'high'; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | type ThemeType = 'light' | 'dark' | 'system'; | 
					
						
							|  |  |  | type NotificationSettingType = 'message' | 'name' | 'count' | 'off'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type IPCEventsValuesType = { | 
					
						
							|  |  |  |   alwaysRelayCalls: boolean | undefined; | 
					
						
							|  |  |  |   audioNotification: boolean | undefined; | 
					
						
							| 
									
										
										
										
											2023-05-08 15:59:36 -04:00
										 |  |  |   audioMessage: boolean; | 
					
						
							| 
									
										
										
										
											2023-12-18 15:22:46 -08:00
										 |  |  |   autoConvertEmoji: boolean; | 
					
						
							| 
									
										
										
										
											2021-08-19 18:56:29 -04:00
										 |  |  |   autoDownloadUpdate: boolean; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   autoLaunch: boolean; | 
					
						
							|  |  |  |   callRingtoneNotification: boolean; | 
					
						
							|  |  |  |   callSystemNotification: boolean; | 
					
						
							|  |  |  |   countMutedConversations: boolean; | 
					
						
							| 
									
										
										
										
											2022-10-04 10:53:36 -07:00
										 |  |  |   hasStoriesDisabled: boolean; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   hideMenuBar: boolean | undefined; | 
					
						
							|  |  |  |   incomingCallNotification: boolean; | 
					
						
							|  |  |  |   lastSyncTime: number | undefined; | 
					
						
							| 
									
										
										
										
											2023-11-06 13:19:23 -08:00
										 |  |  |   localeOverride: string | null; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   notificationDrawAttention: boolean; | 
					
						
							|  |  |  |   notificationSetting: NotificationSettingType; | 
					
						
							|  |  |  |   preferredAudioInputDevice: AudioDevice | undefined; | 
					
						
							|  |  |  |   preferredAudioOutputDevice: AudioDevice | undefined; | 
					
						
							|  |  |  |   preferredVideoInputDevice: string | undefined; | 
					
						
							| 
									
										
										
										
											2022-12-02 18:54:37 -05:00
										 |  |  |   sentMediaQualitySetting: SentMediaQualityType; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   spellCheck: boolean; | 
					
						
							|  |  |  |   systemTraySetting: SystemTraySetting; | 
					
						
							| 
									
										
										
										
											2023-04-14 11:16:28 -07:00
										 |  |  |   textFormatting: boolean; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   themeSetting: ThemeType; | 
					
						
							| 
									
										
										
										
											2022-11-16 12:18:02 -08:00
										 |  |  |   universalExpireTimer: DurationInSeconds; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   zoomFactor: ZoomFactorType; | 
					
						
							| 
									
										
										
										
											2022-10-25 15:18:42 -07:00
										 |  |  |   storyViewReceiptsEnabled: boolean; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Optional
 | 
					
						
							|  |  |  |   mediaPermissions: boolean; | 
					
						
							|  |  |  |   mediaCameraPermissions: boolean; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Only getters
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   blockedCount: number; | 
					
						
							|  |  |  |   linkPreviewSetting: boolean; | 
					
						
							|  |  |  |   phoneNumberDiscoverabilitySetting: PhoneNumberDiscoverability; | 
					
						
							|  |  |  |   phoneNumberSharingSetting: PhoneNumberSharingMode; | 
					
						
							|  |  |  |   readReceiptSetting: boolean; | 
					
						
							|  |  |  |   typingIndicatorSetting: boolean; | 
					
						
							|  |  |  |   deviceName: string | undefined; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type IPCEventsCallbacksType = { | 
					
						
							| 
									
										
										
										
											2023-02-27 14:34:43 -08:00
										 |  |  |   openArtCreator(): Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   getAvailableIODevices(): Promise<{ | 
					
						
							|  |  |  |     availableCameras: Array< | 
					
						
							|  |  |  |       Pick<MediaDeviceInfo, 'deviceId' | 'groupId' | 'kind' | 'label'> | 
					
						
							|  |  |  |     >; | 
					
						
							|  |  |  |     availableMicrophones: Array<AudioDevice>; | 
					
						
							|  |  |  |     availableSpeakers: Array<AudioDevice>; | 
					
						
							|  |  |  |   }>; | 
					
						
							|  |  |  |   addCustomColor: (customColor: CustomColorType) => void; | 
					
						
							|  |  |  |   addDarkOverlay: () => void; | 
					
						
							| 
									
										
										
										
											2023-02-27 14:34:43 -08:00
										 |  |  |   authorizeArtCreator: (data: AuthorizeArtCreatorDataType) => void; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   deleteAllData: () => Promise<void>; | 
					
						
							| 
									
										
										
										
											2022-10-19 12:35:56 -04:00
										 |  |  |   deleteAllMyStories: () => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   editCustomColor: (colorId: string, customColor: CustomColorType) => void; | 
					
						
							|  |  |  |   getConversationsWithCustomColor: (x: string) => Array<ConversationType>; | 
					
						
							| 
									
										
										
										
											2023-11-01 11:03:08 -07:00
										 |  |  |   getMediaAccessStatus: ( | 
					
						
							|  |  |  |     mediaType: 'screen' | 'microphone' | 'camera' | 
					
						
							|  |  |  |   ) => Promise<string | unknown>; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   installStickerPack: (packId: string, key: string) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-08-18 21:04:38 -04:00
										 |  |  |   isPhoneNumberSharingEnabled: () => boolean; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   isPrimary: () => boolean; | 
					
						
							|  |  |  |   removeCustomColor: (x: string) => void; | 
					
						
							|  |  |  |   removeCustomColorOnConversations: (x: string) => void; | 
					
						
							|  |  |  |   removeDarkOverlay: () => void; | 
					
						
							|  |  |  |   resetAllChatColors: () => void; | 
					
						
							|  |  |  |   resetDefaultChatColor: () => void; | 
					
						
							| 
									
										
										
										
											2023-08-01 09:06:29 -07:00
										 |  |  |   showConversationViaNotification: (data: NotificationClickData) => void; | 
					
						
							| 
									
										
										
										
											2023-11-02 12:42:31 -07:00
										 |  |  |   showConversationViaSignalDotMe: ( | 
					
						
							|  |  |  |     kind: string, | 
					
						
							|  |  |  |     value: string | 
					
						
							|  |  |  |   ) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   showKeyboardShortcuts: () => void; | 
					
						
							| 
									
										
										
										
											2023-11-02 12:42:31 -07:00
										 |  |  |   showGroupViaLink: (value: string) => Promise<void>; | 
					
						
							| 
									
										
										
										
											2021-10-22 17:41:45 -07:00
										 |  |  |   showReleaseNotes: () => void; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   showStickerPack: (packId: string, key: string) => void; | 
					
						
							|  |  |  |   shutdown: () => Promise<void>; | 
					
						
							|  |  |  |   unknownSignalLink: () => void; | 
					
						
							|  |  |  |   getCustomColors: () => Record<string, CustomColorType>; | 
					
						
							|  |  |  |   syncRequest: () => Promise<void>; | 
					
						
							|  |  |  |   setGlobalDefaultConversationColor: ( | 
					
						
							|  |  |  |     color: ConversationColorType, | 
					
						
							|  |  |  |     customColor?: { id: string; value: CustomColorType } | 
					
						
							|  |  |  |   ) => void; | 
					
						
							|  |  |  |   getDefaultConversationColor: () => DefaultConversationColorType; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type ValuesWithGetters = Omit< | 
					
						
							|  |  |  |   IPCEventsValuesType, | 
					
						
							| 
									
										
										
										
											2023-12-22 12:27:49 -08:00
										 |  |  |   // Async
 | 
					
						
							|  |  |  |   | 'zoomFactor' | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   // Optional
 | 
					
						
							| 
									
										
										
										
											2023-12-22 12:27:49 -08:00
										 |  |  |   | 'mediaPermissions' | 
					
						
							|  |  |  |   | 'mediaCameraPermissions' | 
					
						
							|  |  |  |   | 'autoLaunch' | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | >; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type ValuesWithSetters = Omit< | 
					
						
							|  |  |  |   IPCEventsValuesType, | 
					
						
							|  |  |  |   | 'blockedCount' | 
					
						
							|  |  |  |   | 'defaultConversationColor' | 
					
						
							|  |  |  |   | 'linkPreviewSetting' | 
					
						
							|  |  |  |   | 'readReceiptSetting' | 
					
						
							|  |  |  |   | 'typingIndicatorSetting' | 
					
						
							|  |  |  |   | 'deviceName' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Optional
 | 
					
						
							|  |  |  |   | 'mediaPermissions' | 
					
						
							|  |  |  |   | 'mediaCameraPermissions' | 
					
						
							|  |  |  | >; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-11 16:43:05 -06:00
										 |  |  | export type IPCEventGetterType<Key extends keyof IPCEventsValuesType> = | 
					
						
							|  |  |  |   `get${Capitalize<Key>}`; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-11 16:43:05 -06:00
										 |  |  | export type IPCEventSetterType<Key extends keyof IPCEventsValuesType> = | 
					
						
							|  |  |  |   `set${Capitalize<Key>}`; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | export type IPCEventsGettersType = { | 
					
						
							|  |  |  |   [Key in keyof ValuesWithGetters as IPCEventGetterType<Key>]: () => ValuesWithGetters[Key]; | 
					
						
							|  |  |  | } & { | 
					
						
							| 
									
										
										
										
											2023-12-22 12:27:49 -08:00
										 |  |  |   // Async
 | 
					
						
							|  |  |  |   getZoomFactor: () => Promise<ZoomFactorType>; | 
					
						
							|  |  |  |   // Events
 | 
					
						
							|  |  |  |   onZoomFactorChange: (callback: (zoomFactor: ZoomFactorType) => void) => void; | 
					
						
							|  |  |  |   // Optional
 | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   getMediaPermissions?: () => Promise<boolean>; | 
					
						
							|  |  |  |   getMediaCameraPermissions?: () => Promise<boolean>; | 
					
						
							| 
									
										
										
										
											2021-10-27 10:54:16 -07:00
										 |  |  |   getAutoLaunch?: () => Promise<boolean>; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type IPCEventsSettersType = { | 
					
						
							|  |  |  |   [Key in keyof ValuesWithSetters as IPCEventSetterType<Key>]: ( | 
					
						
							|  |  |  |     value: NonNullable<ValuesWithSetters[Key]> | 
					
						
							|  |  |  |   ) => Promise<void>; | 
					
						
							|  |  |  | } & { | 
					
						
							|  |  |  |   setMediaPermissions?: (value: boolean) => Promise<void>; | 
					
						
							|  |  |  |   setMediaCameraPermissions?: (value: boolean) => Promise<void>; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export type IPCEventsType = IPCEventsGettersType & | 
					
						
							|  |  |  |   IPCEventsSettersType & | 
					
						
							|  |  |  |   IPCEventsCallbacksType; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export function createIPCEvents( | 
					
						
							|  |  |  |   overrideEvents: Partial<IPCEventsType> = {} | 
					
						
							|  |  |  | ): IPCEventsType { | 
					
						
							| 
									
										
										
										
											2023-02-23 13:32:19 -08:00
										 |  |  |   const setPhoneNumberDiscoverabilitySetting = async ( | 
					
						
							|  |  |  |     newValue: PhoneNumberDiscoverability | 
					
						
							|  |  |  |   ): Promise<void> => { | 
					
						
							|  |  |  |     strictAssert(window.textsecure.server, 'WebAPI must be available'); | 
					
						
							|  |  |  |     await window.storage.put('phoneNumberDiscoverability', newValue); | 
					
						
							|  |  |  |     await window.textsecure.server.setPhoneNumberDiscoverability( | 
					
						
							|  |  |  |       newValue === PhoneNumberDiscoverability.Discoverable | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     const account = window.ConversationController.getOurConversationOrThrow(); | 
					
						
							|  |  |  |     account.captureChange('phoneNumberDiscoverability'); | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |   return { | 
					
						
							| 
									
										
										
										
											2023-02-27 14:34:43 -08:00
										 |  |  |     openArtCreator: async () => { | 
					
						
							|  |  |  |       const auth = await window.textsecure.server?.getArtAuth(); | 
					
						
							|  |  |  |       if (!auth) { | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       window.openArtCreator(auth); | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     getDeviceName: () => window.textsecure.storage.user.getDeviceName(), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-22 12:27:49 -08:00
										 |  |  |     getZoomFactor: () => { | 
					
						
							|  |  |  |       return ipcRenderer.invoke('getZoomFactor'); | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     setZoomFactor: async zoomFactor => { | 
					
						
							|  |  |  |       ipcRenderer.send('setZoomFactor', zoomFactor); | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     onZoomFactorChange: callback => { | 
					
						
							|  |  |  |       ipcRenderer.on('zoomFactorChanged', (_event, zoomFactor) => { | 
					
						
							|  |  |  |         callback(zoomFactor); | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-23 13:32:19 -08:00
										 |  |  |     setPhoneNumberDiscoverabilitySetting, | 
					
						
							|  |  |  |     setPhoneNumberSharingSetting: async (newValue: PhoneNumberSharingMode) => { | 
					
						
							|  |  |  |       const account = window.ConversationController.getOurConversationOrThrow(); | 
					
						
							|  |  |  |       const promises = new Array<Promise<void>>(); | 
					
						
							|  |  |  |       promises.push(window.storage.put('phoneNumberSharingMode', newValue)); | 
					
						
							|  |  |  |       if (newValue === PhoneNumberSharingMode.Everybody) { | 
					
						
							|  |  |  |         promises.push( | 
					
						
							|  |  |  |           setPhoneNumberDiscoverabilitySetting( | 
					
						
							|  |  |  |             PhoneNumberDiscoverability.Discoverable | 
					
						
							|  |  |  |           ) | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       account.captureChange('phoneNumberSharingMode'); | 
					
						
							|  |  |  |       await Promise.all(promises); | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-04 10:53:36 -07:00
										 |  |  |     getHasStoriesDisabled: () => | 
					
						
							|  |  |  |       window.storage.get('hasStoriesDisabled', false), | 
					
						
							|  |  |  |     setHasStoriesDisabled: async (value: boolean) => { | 
					
						
							|  |  |  |       await window.storage.put('hasStoriesDisabled', value); | 
					
						
							|  |  |  |       const account = window.ConversationController.getOurConversationOrThrow(); | 
					
						
							|  |  |  |       account.captureChange('hasStoriesDisabled'); | 
					
						
							| 
									
										
										
										
											2022-10-04 17:48:25 -07:00
										 |  |  |       window.textsecure.server?.onHasStoriesDisabledChange(value); | 
					
						
							| 
									
										
										
										
											2022-10-04 10:53:36 -07:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2022-10-25 15:18:42 -07:00
										 |  |  |     getStoryViewReceiptsEnabled: () => { | 
					
						
							|  |  |  |       return ( | 
					
						
							|  |  |  |         window.storage.get('storyViewReceiptsEnabled') ?? | 
					
						
							|  |  |  |         window.storage.get('read-receipt-setting') ?? | 
					
						
							|  |  |  |         false | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     setStoryViewReceiptsEnabled: async (value: boolean) => { | 
					
						
							|  |  |  |       await window.storage.put('storyViewReceiptsEnabled', value); | 
					
						
							| 
									
										
										
										
											2023-02-23 13:32:19 -08:00
										 |  |  |       const account = window.ConversationController.getOurConversationOrThrow(); | 
					
						
							|  |  |  |       account.captureChange('storyViewReceiptsEnabled'); | 
					
						
							| 
									
										
										
										
											2022-10-25 15:18:42 -07:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2022-07-19 20:47:05 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     getPreferredAudioInputDevice: () => | 
					
						
							|  |  |  |       window.storage.get('preferred-audio-input-device'), | 
					
						
							|  |  |  |     setPreferredAudioInputDevice: device => | 
					
						
							|  |  |  |       window.storage.put('preferred-audio-input-device', device), | 
					
						
							|  |  |  |     getPreferredAudioOutputDevice: () => | 
					
						
							|  |  |  |       window.storage.get('preferred-audio-output-device'), | 
					
						
							|  |  |  |     setPreferredAudioOutputDevice: device => | 
					
						
							|  |  |  |       window.storage.put('preferred-audio-output-device', device), | 
					
						
							|  |  |  |     getPreferredVideoInputDevice: () => | 
					
						
							|  |  |  |       window.storage.get('preferred-video-input-device'), | 
					
						
							|  |  |  |     setPreferredVideoInputDevice: device => | 
					
						
							|  |  |  |       window.storage.put('preferred-video-input-device', device), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-19 12:35:56 -04:00
										 |  |  |     deleteAllMyStories: async () => { | 
					
						
							|  |  |  |       await deleteAllMyStories(); | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     // Chat Color redux hookups
 | 
					
						
							|  |  |  |     getCustomColors: () => { | 
					
						
							|  |  |  |       return getCustomColors(window.reduxStore.getState()) || {}; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     getConversationsWithCustomColor: colorId => { | 
					
						
							|  |  |  |       return getConversationsWithCustomColorSelector( | 
					
						
							|  |  |  |         window.reduxStore.getState() | 
					
						
							|  |  |  |       )(colorId); | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     addCustomColor: (...args) => | 
					
						
							|  |  |  |       window.reduxActions.items.addCustomColor(...args), | 
					
						
							|  |  |  |     editCustomColor: (...args) => | 
					
						
							|  |  |  |       window.reduxActions.items.editCustomColor(...args), | 
					
						
							|  |  |  |     removeCustomColor: colorId => | 
					
						
							|  |  |  |       window.reduxActions.items.removeCustomColor(colorId), | 
					
						
							|  |  |  |     removeCustomColorOnConversations: colorId => | 
					
						
							|  |  |  |       window.reduxActions.conversations.removeCustomColorOnConversations( | 
					
						
							|  |  |  |         colorId | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     resetAllChatColors: () => | 
					
						
							|  |  |  |       window.reduxActions.conversations.resetAllChatColors(), | 
					
						
							|  |  |  |     resetDefaultChatColor: () => | 
					
						
							|  |  |  |       window.reduxActions.items.resetDefaultChatColor(), | 
					
						
							|  |  |  |     setGlobalDefaultConversationColor: (...args) => | 
					
						
							|  |  |  |       window.reduxActions.items.setGlobalDefaultConversationColor(...args), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Getters only
 | 
					
						
							|  |  |  |     getAvailableIODevices: async () => { | 
					
						
							| 
									
										
										
										
											2021-11-11 16:43:05 -06:00
										 |  |  |       const { availableCameras, availableMicrophones, availableSpeakers } = | 
					
						
							|  |  |  |         await calling.getAvailableIODevices(); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |       return { | 
					
						
							|  |  |  |         // mapping it to a pojo so that it is IPC friendly
 | 
					
						
							|  |  |  |         availableCameras: availableCameras.map( | 
					
						
							|  |  |  |           (inputDeviceInfo: MediaDeviceInfo) => ({ | 
					
						
							|  |  |  |             deviceId: inputDeviceInfo.deviceId, | 
					
						
							|  |  |  |             groupId: inputDeviceInfo.groupId, | 
					
						
							|  |  |  |             kind: inputDeviceInfo.kind, | 
					
						
							|  |  |  |             label: inputDeviceInfo.label, | 
					
						
							|  |  |  |           }) | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         availableMicrophones, | 
					
						
							|  |  |  |         availableSpeakers, | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     getBlockedCount: () => | 
					
						
							| 
									
										
										
										
											2023-08-16 22:54:39 +02:00
										 |  |  |       window.storage.blocked.getBlockedServiceIds().length + | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |       window.storage.blocked.getBlockedGroups().length, | 
					
						
							|  |  |  |     getDefaultConversationColor: () => | 
					
						
							|  |  |  |       window.storage.get( | 
					
						
							|  |  |  |         'defaultConversationColor', | 
					
						
							|  |  |  |         DEFAULT_CONVERSATION_COLOR | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     getLinkPreviewSetting: () => window.storage.get('linkPreviews', false), | 
					
						
							|  |  |  |     getPhoneNumberDiscoverabilitySetting: () => | 
					
						
							|  |  |  |       window.storage.get( | 
					
						
							|  |  |  |         'phoneNumberDiscoverability', | 
					
						
							|  |  |  |         PhoneNumberDiscoverability.NotDiscoverable | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     getPhoneNumberSharingSetting: () => | 
					
						
							|  |  |  |       window.storage.get( | 
					
						
							|  |  |  |         'phoneNumberSharingMode', | 
					
						
							|  |  |  |         PhoneNumberSharingMode.Nobody | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     getReadReceiptSetting: () => | 
					
						
							|  |  |  |       window.storage.get('read-receipt-setting', false), | 
					
						
							|  |  |  |     getTypingIndicatorSetting: () => | 
					
						
							|  |  |  |       window.storage.get('typingIndicators', false), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Configurable settings
 | 
					
						
							| 
									
										
										
										
											2021-08-19 18:56:29 -04:00
										 |  |  |     getAutoDownloadUpdate: () => | 
					
						
							|  |  |  |       window.storage.get('auto-download-update', true), | 
					
						
							|  |  |  |     setAutoDownloadUpdate: value => | 
					
						
							|  |  |  |       window.storage.put('auto-download-update', value), | 
					
						
							| 
									
										
										
										
											2023-12-18 15:22:46 -08:00
										 |  |  |     getAutoConvertEmoji: () => window.storage.get('autoConvertEmoji', false), | 
					
						
							|  |  |  |     setAutoConvertEmoji: value => window.storage.put('autoConvertEmoji', value), | 
					
						
							| 
									
										
										
										
											2022-12-02 18:54:37 -05:00
										 |  |  |     getSentMediaQualitySetting: () => | 
					
						
							|  |  |  |       window.storage.get('sent-media-quality', 'standard'), | 
					
						
							|  |  |  |     setSentMediaQualitySetting: value => | 
					
						
							|  |  |  |       window.storage.put('sent-media-quality', value), | 
					
						
							| 
									
										
										
										
											2021-12-20 17:58:21 +01:00
										 |  |  |     getThemeSetting: () => window.storage.get('theme-setting', 'system'), | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     setThemeSetting: value => { | 
					
						
							|  |  |  |       const promise = window.storage.put('theme-setting', value); | 
					
						
							|  |  |  |       themeChanged(); | 
					
						
							|  |  |  |       return promise; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     getHideMenuBar: () => window.storage.get('hide-menu-bar'), | 
					
						
							|  |  |  |     setHideMenuBar: value => { | 
					
						
							|  |  |  |       const promise = window.storage.put('hide-menu-bar', value); | 
					
						
							| 
									
										
										
										
											2023-01-12 19:24:59 -05:00
										 |  |  |       window.IPC.setAutoHideMenuBar(value); | 
					
						
							|  |  |  |       window.IPC.setMenuBarVisibility(!value); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |       return promise; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     getSystemTraySetting: () => | 
					
						
							|  |  |  |       parseSystemTraySetting(window.storage.get('system-tray-setting')), | 
					
						
							|  |  |  |     setSystemTraySetting: value => { | 
					
						
							|  |  |  |       const promise = window.storage.put('system-tray-setting', value); | 
					
						
							| 
									
										
										
										
											2023-01-12 19:24:59 -05:00
										 |  |  |       window.IPC.updateSystemTraySetting(value); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |       return promise; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-06 13:19:23 -08:00
										 |  |  |     getLocaleOverride: () => { | 
					
						
							|  |  |  |       return window.storage.get('localeOverride') ?? null; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     setLocaleOverride: async (locale: string | null) => { | 
					
						
							|  |  |  |       await window.storage.put('localeOverride', locale); | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     getNotificationSetting: () => | 
					
						
							|  |  |  |       window.storage.get('notification-setting', 'message'), | 
					
						
							|  |  |  |     setNotificationSetting: (value: 'message' | 'name' | 'count' | 'off') => | 
					
						
							|  |  |  |       window.storage.put('notification-setting', value), | 
					
						
							|  |  |  |     getNotificationDrawAttention: () => | 
					
						
							| 
									
										
										
										
											2023-01-31 18:03:44 -08:00
										 |  |  |       window.storage.get('notification-draw-attention', false), | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     setNotificationDrawAttention: value => | 
					
						
							|  |  |  |       window.storage.put('notification-draw-attention', value), | 
					
						
							| 
									
										
										
										
											2023-05-08 15:59:36 -04:00
										 |  |  |     getAudioMessage: () => window.storage.get('audioMessage', false), | 
					
						
							|  |  |  |     setAudioMessage: value => window.storage.put('audioMessage', value), | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     getAudioNotification: () => window.storage.get('audio-notification'), | 
					
						
							|  |  |  |     setAudioNotification: value => | 
					
						
							|  |  |  |       window.storage.put('audio-notification', value), | 
					
						
							|  |  |  |     getCountMutedConversations: () => | 
					
						
							|  |  |  |       window.storage.get('badge-count-muted-conversations', false), | 
					
						
							|  |  |  |     setCountMutedConversations: value => { | 
					
						
							|  |  |  |       const promise = window.storage.put( | 
					
						
							|  |  |  |         'badge-count-muted-conversations', | 
					
						
							|  |  |  |         value | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |       window.Whisper.events.trigger('updateUnreadCount'); | 
					
						
							|  |  |  |       return promise; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     getCallRingtoneNotification: () => | 
					
						
							|  |  |  |       window.storage.get('call-ringtone-notification', true), | 
					
						
							|  |  |  |     setCallRingtoneNotification: value => | 
					
						
							|  |  |  |       window.storage.put('call-ringtone-notification', value), | 
					
						
							|  |  |  |     getCallSystemNotification: () => | 
					
						
							|  |  |  |       window.storage.get('call-system-notification', true), | 
					
						
							|  |  |  |     setCallSystemNotification: value => | 
					
						
							|  |  |  |       window.storage.put('call-system-notification', value), | 
					
						
							|  |  |  |     getIncomingCallNotification: () => | 
					
						
							|  |  |  |       window.storage.get('incoming-call-notification', true), | 
					
						
							|  |  |  |     setIncomingCallNotification: value => | 
					
						
							|  |  |  |       window.storage.put('incoming-call-notification', value), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     getSpellCheck: () => window.storage.get('spell-check', true), | 
					
						
							|  |  |  |     setSpellCheck: value => window.storage.put('spell-check', value), | 
					
						
							| 
									
										
										
										
											2023-04-14 11:16:28 -07:00
										 |  |  |     getTextFormatting: () => window.storage.get('textFormatting', true), | 
					
						
							|  |  |  |     setTextFormatting: value => window.storage.put('textFormatting', value), | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     getAlwaysRelayCalls: () => window.storage.get('always-relay-calls'), | 
					
						
							|  |  |  |     setAlwaysRelayCalls: value => | 
					
						
							|  |  |  |       window.storage.put('always-relay-calls', value), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-12 19:24:59 -05:00
										 |  |  |     getAutoLaunch: () => window.IPC.getAutoLaunch(), | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     setAutoLaunch: async (value: boolean) => { | 
					
						
							| 
									
										
										
										
											2023-01-12 19:24:59 -05:00
										 |  |  |       return window.IPC.setAutoLaunch(value); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-18 21:04:38 -04:00
										 |  |  |     isPhoneNumberSharingEnabled: () => isPhoneNumberSharingEnabled(), | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     isPrimary: () => window.textsecure.storage.user.getDeviceId() === 1, | 
					
						
							|  |  |  |     syncRequest: () => | 
					
						
							|  |  |  |       new Promise<void>((resolve, reject) => { | 
					
						
							| 
									
										
										
										
											2021-08-26 09:10:58 -05:00
										 |  |  |         const FIVE_MINUTES = 5 * durations.MINUTE; | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |         const syncRequest = window.getSyncRequest(FIVE_MINUTES); | 
					
						
							|  |  |  |         syncRequest.addEventListener('success', () => resolve()); | 
					
						
							|  |  |  |         syncRequest.addEventListener('timeout', () => | 
					
						
							|  |  |  |           reject(new Error('timeout')) | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       }), | 
					
						
							|  |  |  |     getLastSyncTime: () => window.storage.get('synced_at'), | 
					
						
							|  |  |  |     setLastSyncTime: value => window.storage.put('synced_at', value), | 
					
						
							|  |  |  |     getUniversalExpireTimer: () => universalExpireTimer.get(), | 
					
						
							|  |  |  |     setUniversalExpireTimer: async newValue => { | 
					
						
							|  |  |  |       await universalExpireTimer.set(newValue); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // Update account in Storage Service
 | 
					
						
							| 
									
										
										
										
											2022-10-04 10:53:36 -07:00
										 |  |  |       const account = window.ConversationController.getOurConversationOrThrow(); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |       account.captureChange('universalExpireTimer'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // Add a notification to the currently open conversation
 | 
					
						
							|  |  |  |       const state = window.reduxStore.getState(); | 
					
						
							|  |  |  |       const selectedId = state.conversations.selectedConversationId; | 
					
						
							|  |  |  |       if (selectedId) { | 
					
						
							|  |  |  |         const conversation = window.ConversationController.get(selectedId); | 
					
						
							| 
									
										
										
										
											2022-09-15 12:17:15 -07:00
										 |  |  |         assertDev(conversation, "Conversation wasn't found"); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         await conversation.updateLastMessage(); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     addDarkOverlay: () => { | 
					
						
							| 
									
										
										
										
											2022-11-29 16:53:39 -08:00
										 |  |  |       const elems = document.querySelectorAll('.dark-overlay'); | 
					
						
							|  |  |  |       if (elems.length) { | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-11-29 16:53:39 -08:00
										 |  |  |       const newOverlay = document.createElement('div'); | 
					
						
							|  |  |  |       newOverlay.className = 'dark-overlay'; | 
					
						
							|  |  |  |       newOverlay.addEventListener('click', () => { | 
					
						
							|  |  |  |         newOverlay.remove(); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |       document.body.prepend(newOverlay); | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2023-02-27 14:34:43 -08:00
										 |  |  |     authorizeArtCreator: (data: AuthorizeArtCreatorDataType) => { | 
					
						
							|  |  |  |       // We can get these events even if the user has never linked this instance.
 | 
					
						
							| 
									
										
										
										
											2023-04-10 20:54:43 -07:00
										 |  |  |       if (!Registration.everDone()) { | 
					
						
							| 
									
										
										
										
											2023-02-27 14:34:43 -08:00
										 |  |  |         log.warn('authorizeArtCreator: Not registered, returning early'); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       window.reduxActions.globalModals.showAuthorizeArtCreator(data); | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2022-11-29 16:53:39 -08:00
										 |  |  |     removeDarkOverlay: () => { | 
					
						
							|  |  |  |       const elems = document.querySelectorAll('.dark-overlay'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       for (const elem of elems) { | 
					
						
							|  |  |  |         elem.remove(); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2022-12-21 22:07:45 -05:00
										 |  |  |     showKeyboardShortcuts: () => | 
					
						
							|  |  |  |       window.reduxActions.globalModals.showShortcutGuideModal(), | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     deleteAllData: async () => { | 
					
						
							| 
									
										
										
										
											2021-08-24 16:57:34 -04:00
										 |  |  |       renderClearingDataView(); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     showStickerPack: (packId, key) => { | 
					
						
							|  |  |  |       // We can get these events even if the user has never linked this instance.
 | 
					
						
							| 
									
										
										
										
											2023-04-10 20:54:43 -07:00
										 |  |  |       if (!Registration.everDone()) { | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  |         log.warn('showStickerPack: Not registered, returning early'); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-12-09 14:01:46 -05:00
										 |  |  |       window.reduxActions.globalModals.showStickerPackPreview(packId, key); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2023-11-02 12:42:31 -07:00
										 |  |  |     showGroupViaLink: async value => { | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |       // We can get these events even if the user has never linked this instance.
 | 
					
						
							| 
									
										
										
										
											2023-04-10 20:54:43 -07:00
										 |  |  |       if (!Registration.everDone()) { | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  |         log.warn('showGroupViaLink: Not registered, returning early'); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       try { | 
					
						
							| 
									
										
										
										
											2023-11-02 12:42:31 -07:00
										 |  |  |         await window.Signal.Groups.joinViaLink(value); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |       } catch (error) { | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  |         log.error( | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |           'showGroupViaLink: Ran into an error!', | 
					
						
							| 
									
										
										
										
											2022-11-22 10:43:43 -08:00
										 |  |  |           Errors.toLogFormat(error) | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |         ); | 
					
						
							| 
									
										
										
										
											2022-12-21 22:07:45 -05:00
										 |  |  |         window.reduxActions.globalModals.showErrorModal({ | 
					
						
							| 
									
										
										
										
											2023-03-29 17:03:25 -07:00
										 |  |  |           title: window.i18n('icu:GroupV2--join--general-join-failure--title'), | 
					
						
							|  |  |  |           description: window.i18n('icu:GroupV2--join--general-join-failure'), | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |         }); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2023-08-01 09:06:29 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     showConversationViaNotification({ | 
					
						
							|  |  |  |       conversationId, | 
					
						
							|  |  |  |       messageId, | 
					
						
							|  |  |  |       storyId, | 
					
						
							|  |  |  |     }: NotificationClickData) { | 
					
						
							|  |  |  |       if (conversationId) { | 
					
						
							|  |  |  |         if (storyId) { | 
					
						
							|  |  |  |           window.reduxActions.stories.viewStory({ | 
					
						
							|  |  |  |             storyId, | 
					
						
							|  |  |  |             storyViewMode: StoryViewModeType.Single, | 
					
						
							|  |  |  |             viewTarget: StoryViewTargetType.Replies, | 
					
						
							|  |  |  |           }); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           window.reduxActions.conversations.showConversation({ | 
					
						
							|  |  |  |             conversationId, | 
					
						
							| 
									
										
										
										
											2023-11-02 12:42:31 -07:00
										 |  |  |             messageId: messageId ?? undefined, | 
					
						
							| 
									
										
										
										
											2023-08-01 09:06:29 -07:00
										 |  |  |           }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         window.reduxActions.app.openInbox(); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2023-11-02 12:42:31 -07:00
										 |  |  |     async showConversationViaSignalDotMe(kind: string, value: string) { | 
					
						
							| 
									
										
										
										
											2023-04-10 20:54:43 -07:00
										 |  |  |       if (!Registration.everDone()) { | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  |         log.info( | 
					
						
							| 
									
										
										
										
											2021-08-28 08:27:38 -05:00
										 |  |  |           'showConversationViaSignalDotMe: Not registered, returning early' | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-18 10:12:02 -07:00
										 |  |  |       const { showUserNotFoundModal } = window.reduxActions.globalModals; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-02 12:42:31 -07:00
										 |  |  |       let conversationId: string | undefined; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (kind === 'phoneNumber') { | 
					
						
							|  |  |  |         if (isValidE164(value, true)) { | 
					
						
							|  |  |  |           conversationId = await lookupConversationWithoutServiceId({ | 
					
						
							|  |  |  |             type: 'e164', | 
					
						
							|  |  |  |             e164: value, | 
					
						
							|  |  |  |             phoneNumber: value, | 
					
						
							|  |  |  |             showUserNotFoundModal, | 
					
						
							|  |  |  |             setIsFetchingUUID: noop, | 
					
						
							|  |  |  |           }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } else if (kind === 'encryptedUsername') { | 
					
						
							|  |  |  |         const usernameBase64 = fromWebSafeBase64(value); | 
					
						
							|  |  |  |         const username = await resolveUsernameByLinkBase64(usernameBase64); | 
					
						
							|  |  |  |         if (username != null) { | 
					
						
							|  |  |  |           conversationId = await lookupConversationWithoutServiceId({ | 
					
						
							|  |  |  |             type: 'username', | 
					
						
							|  |  |  |             username, | 
					
						
							|  |  |  |             showUserNotFoundModal, | 
					
						
							|  |  |  |             setIsFetchingUUID: noop, | 
					
						
							| 
									
										
										
										
											2022-12-14 11:05:32 -08:00
										 |  |  |           }); | 
					
						
							| 
									
										
										
										
											2022-10-18 10:12:02 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-08-28 19:01:41 +02:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2023-07-20 05:14:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-02 12:42:31 -07:00
										 |  |  |       if (conversationId != null) { | 
					
						
							|  |  |  |         window.reduxActions.conversations.showConversation({ | 
					
						
							|  |  |  |           conversationId, | 
					
						
							| 
									
										
										
										
											2022-08-24 10:33:48 -07:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2022-12-13 14:55:33 -08:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2021-08-28 08:27:38 -05:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  |       log.info('showConversationViaSignalDotMe: invalid E164'); | 
					
						
							| 
									
										
										
										
											2022-12-09 14:01:46 -05:00
										 |  |  |       showUnknownSgnlLinkModal(); | 
					
						
							| 
									
										
										
										
											2021-08-28 08:27:38 -05:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     unknownSignalLink: () => { | 
					
						
							| 
									
										
										
										
											2021-09-17 14:27:53 -04:00
										 |  |  |       log.warn('unknownSignalLink: Showing error dialog'); | 
					
						
							| 
									
										
										
										
											2021-08-28 08:27:38 -05:00
										 |  |  |       showUnknownSgnlLinkModal(); | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     installStickerPack: async (packId, key) => { | 
					
						
							| 
									
										
										
										
											2022-12-21 10:41:48 -08:00
										 |  |  |       void Stickers.downloadStickerPack(packId, key, { | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  |         finalStatus: 'installed', | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     shutdown: () => Promise.resolve(), | 
					
						
							| 
									
										
										
										
											2021-10-22 17:41:45 -07:00
										 |  |  |     showReleaseNotes: () => { | 
					
						
							|  |  |  |       const { showWhatsNewModal } = window.reduxActions.globalModals; | 
					
						
							|  |  |  |       showWhatsNewModal(); | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-01 11:03:08 -07:00
										 |  |  |     getMediaAccessStatus: async ( | 
					
						
							|  |  |  |       mediaType: 'screen' | 'microphone' | 'camera' | 
					
						
							|  |  |  |     ) => { | 
					
						
							|  |  |  |       return window.IPC.getMediaAccessStatus(mediaType); | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2023-01-12 19:24:59 -05:00
										 |  |  |     getMediaPermissions: window.IPC.getMediaPermissions, | 
					
						
							|  |  |  |     getMediaCameraPermissions: window.IPC.getMediaCameraPermissions, | 
					
						
							| 
									
										
										
										
											2021-08-18 16:08:14 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ...overrideEvents, | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-08-28 08:27:38 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | function showUnknownSgnlLinkModal(): void { | 
					
						
							| 
									
										
										
										
											2022-12-21 22:07:45 -05:00
										 |  |  |   window.reduxActions.globalModals.showErrorModal({ | 
					
						
							| 
									
										
										
										
											2023-03-29 17:03:25 -07:00
										 |  |  |     description: window.i18n('icu:unknown-sgnl-link'), | 
					
						
							| 
									
										
										
										
											2021-08-28 08:27:38 -05:00
										 |  |  |   }); | 
					
						
							|  |  |  | } |