signal-desktop/ts/util/createIPCEvents.ts

598 lines
22 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2020 Signal Messenger, LLC
2021-08-18 20:08:14 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import { webFrame } from 'electron';
2023-01-09 18:38:57 +00:00
import type { AudioDevice } from '@signalapp/ringrtc';
2022-10-18 17:12:02 +00:00
import { noop } from 'lodash';
import { getStoriesAvailable } from './stories';
2021-08-18 20:08:14 +00:00
import type { ZoomFactorType } from '../types/Storage.d';
import type {
2021-08-18 20:08:14 +00:00
ConversationColorType,
CustomColorType,
DefaultConversationColorType,
} from '../types/Colors';
import { DEFAULT_CONVERSATION_COLOR } from '../types/Colors';
import * as Errors from '../types/errors';
2021-08-18 20:08:14 +00:00
import * as Stickers from '../types/Stickers';
import type { SystemTraySetting } from '../types/SystemTraySetting';
import { parseSystemTraySetting } from '../types/SystemTraySetting';
2021-08-18 20:08:14 +00:00
import type { ConversationType } from '../state/ducks/conversations';
2023-02-27 22:34:43 +00:00
import type { AuthorizeArtCreatorDataType } from '../state/ducks/globalModals';
2021-08-18 20:08:14 +00:00
import { calling } from '../services/calling';
2023-07-20 03:14:08 +00:00
import { resolveUsernameByLinkBase64 } from '../services/username';
2021-08-18 20:08:14 +00:00
import { getConversationsWithCustomColorSelector } from '../state/selectors/conversations';
import { getCustomColors } from '../state/selectors/items';
import { themeChanged } from '../shims/themeChanged';
2021-08-24 20:57:34 +00:00
import { renderClearingDataView } from '../shims/renderClearingDataView';
2021-08-18 20:08:14 +00:00
import * as universalExpireTimer from './universalExpireTimer';
import { PhoneNumberDiscoverability } from './phoneNumberDiscoverability';
import { PhoneNumberSharingMode } from './phoneNumberSharingMode';
2023-02-23 21:32:19 +00:00
import { strictAssert, assertDev } from './assert';
import * as durations from './durations';
2022-11-16 20:18:02 +00:00
import type { DurationInSeconds } from './durations';
2021-08-19 01:04:38 +00:00
import { isPhoneNumberSharingEnabled } from './isPhoneNumberSharingEnabled';
2023-04-11 03:54:43 +00:00
import * as Registration from './registration';
2022-10-18 17:12:02 +00:00
import {
parseE164FromSignalDotMeHash,
2023-07-20 03:14:08 +00:00
parseUsernameBase64FromSignalDotMeHash,
2022-10-18 17:12:02 +00:00
} from './sgnlHref';
import { lookupConversationWithoutUuid } from './lookupConversationWithoutUuid';
import * as log from '../logging/log';
import { deleteAllMyStories } from './deleteAllMyStories';
import { isEnabled } from '../RemoteConfig';
2021-08-18 20:08:14 +00:00
type SentMediaQualityType = 'standard' | 'high';
2021-08-18 20:08:14 +00:00
type ThemeType = 'light' | 'dark' | 'system';
type NotificationSettingType = 'message' | 'name' | 'count' | 'off';
export type IPCEventsValuesType = {
alwaysRelayCalls: boolean | undefined;
audioNotification: boolean | undefined;
audioMessage: boolean;
autoDownloadUpdate: boolean;
2021-08-18 20:08:14 +00:00
autoLaunch: boolean;
callRingtoneNotification: boolean;
callSystemNotification: boolean;
countMutedConversations: boolean;
hasStoriesDisabled: boolean;
2021-08-18 20:08:14 +00:00
hideMenuBar: boolean | undefined;
incomingCallNotification: boolean;
lastSyncTime: number | undefined;
notificationDrawAttention: boolean;
notificationSetting: NotificationSettingType;
preferredAudioInputDevice: AudioDevice | undefined;
preferredAudioOutputDevice: AudioDevice | undefined;
preferredVideoInputDevice: string | undefined;
sentMediaQualitySetting: SentMediaQualityType;
2021-08-18 20:08:14 +00:00
spellCheck: boolean;
systemTraySetting: SystemTraySetting;
textFormatting: boolean;
2021-08-18 20:08:14 +00:00
themeSetting: ThemeType;
2022-11-16 20:18:02 +00:00
universalExpireTimer: DurationInSeconds;
2021-08-18 20:08:14 +00:00
zoomFactor: ZoomFactorType;
2022-10-25 22:18:42 +00:00
storyViewReceiptsEnabled: boolean;
2021-08-18 20:08:14 +00: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 22:34:43 +00:00
openArtCreator(): Promise<void>;
2021-08-18 20:08:14 +00: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 22:34:43 +00:00
authorizeArtCreator: (data: AuthorizeArtCreatorDataType) => void;
2021-08-18 20:08:14 +00:00
deleteAllData: () => Promise<void>;
deleteAllMyStories: () => Promise<void>;
2021-08-18 20:08:14 +00:00
editCustomColor: (colorId: string, customColor: CustomColorType) => void;
getConversationsWithCustomColor: (x: string) => Array<ConversationType>;
installStickerPack: (packId: string, key: string) => Promise<void>;
isFormattingFlagEnabled: () => boolean;
2021-08-19 01:04:38 +00:00
isPhoneNumberSharingEnabled: () => boolean;
2021-08-18 20:08:14 +00:00
isPrimary: () => boolean;
removeCustomColor: (x: string) => void;
removeCustomColorOnConversations: (x: string) => void;
removeDarkOverlay: () => void;
resetAllChatColors: () => void;
resetDefaultChatColor: () => void;
2022-10-18 17:12:02 +00:00
showConversationViaSignalDotMe: (hash: string) => Promise<void>;
2021-08-18 20:08:14 +00:00
showKeyboardShortcuts: () => void;
showGroupViaLink: (x: string) => Promise<void>;
showReleaseNotes: () => void;
2021-08-18 20:08:14 +00: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;
2022-07-20 00:47:05 +00:00
shouldShowStoriesSettings: () => boolean;
2021-08-18 20:08:14 +00:00
getDefaultConversationColor: () => DefaultConversationColorType;
persistZoomFactor: (factor: number) => Promise<void>;
2021-08-18 20:08:14 +00:00
};
type ValuesWithGetters = Omit<
IPCEventsValuesType,
// Optional
2021-10-27 17:54:16 +00:00
'mediaPermissions' | 'mediaCameraPermissions' | 'autoLaunch'
2021-08-18 20:08:14 +00:00
>;
type ValuesWithSetters = Omit<
IPCEventsValuesType,
| 'blockedCount'
| 'defaultConversationColor'
| 'linkPreviewSetting'
| 'readReceiptSetting'
| 'typingIndicatorSetting'
| 'deviceName'
// Optional
| 'mediaPermissions'
| 'mediaCameraPermissions'
>;
2021-11-11 22:43:05 +00:00
export type IPCEventGetterType<Key extends keyof IPCEventsValuesType> =
`get${Capitalize<Key>}`;
2021-08-18 20:08:14 +00:00
2021-11-11 22:43:05 +00:00
export type IPCEventSetterType<Key extends keyof IPCEventsValuesType> =
`set${Capitalize<Key>}`;
2021-08-18 20:08:14 +00:00
export type IPCEventsGettersType = {
[Key in keyof ValuesWithGetters as IPCEventGetterType<Key>]: () => ValuesWithGetters[Key];
} & {
getMediaPermissions?: () => Promise<boolean>;
getMediaCameraPermissions?: () => Promise<boolean>;
2021-10-27 17:54:16 +00:00
getAutoLaunch?: () => Promise<boolean>;
2021-08-18 20:08:14 +00: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 21:32:19 +00: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 20:08:14 +00:00
return {
2023-02-27 22:34:43 +00:00
openArtCreator: async () => {
const auth = await window.textsecure.server?.getArtAuth();
if (!auth) {
return;
}
window.openArtCreator(auth);
},
2021-08-18 20:08:14 +00:00
getDeviceName: () => window.textsecure.storage.user.getDeviceName(),
getZoomFactor: () => window.storage.get('zoomFactor', 1),
2021-09-02 23:29:16 +00:00
setZoomFactor: async (zoomFactor: ZoomFactorType) => {
webFrame.setZoomFactor(zoomFactor);
2021-08-18 20:08:14 +00:00
},
2023-02-23 21:32:19 +00: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);
},
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-05 00:48:25 +00:00
window.textsecure.server?.onHasStoriesDisabledChange(value);
},
2022-10-25 22:18:42 +00: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 21:32:19 +00:00
const account = window.ConversationController.getOurConversationOrThrow();
account.captureChange('storyViewReceiptsEnabled');
2022-10-25 22:18:42 +00:00
},
2022-07-20 00:47:05 +00:00
2021-08-18 20:08:14 +00: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),
deleteAllMyStories: async () => {
await deleteAllMyStories();
},
2021-08-18 20:08:14 +00: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 22:43:05 +00:00
const { availableCameras, availableMicrophones, availableSpeakers } =
await calling.getAvailableIODevices();
2021-08-18 20:08:14 +00: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: () =>
window.storage.blocked.getBlockedUuids().length +
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
getAutoDownloadUpdate: () =>
window.storage.get('auto-download-update', true),
setAutoDownloadUpdate: value =>
window.storage.put('auto-download-update', value),
getSentMediaQualitySetting: () =>
window.storage.get('sent-media-quality', 'standard'),
setSentMediaQualitySetting: value =>
window.storage.put('sent-media-quality', value),
2021-12-20 16:58:21 +00:00
getThemeSetting: () => window.storage.get('theme-setting', 'system'),
2021-08-18 20:08:14 +00: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-13 00:24:59 +00:00
window.IPC.setAutoHideMenuBar(value);
window.IPC.setMenuBarVisibility(!value);
2021-08-18 20:08:14 +00:00
return promise;
},
getSystemTraySetting: () =>
parseSystemTraySetting(window.storage.get('system-tray-setting')),
setSystemTraySetting: value => {
const promise = window.storage.put('system-tray-setting', value);
2023-01-13 00:24:59 +00:00
window.IPC.updateSystemTraySetting(value);
2021-08-18 20:08:14 +00:00
return promise;
},
getNotificationSetting: () =>
window.storage.get('notification-setting', 'message'),
setNotificationSetting: (value: 'message' | 'name' | 'count' | 'off') =>
window.storage.put('notification-setting', value),
getNotificationDrawAttention: () =>
window.storage.get('notification-draw-attention', false),
2021-08-18 20:08:14 +00:00
setNotificationDrawAttention: value =>
window.storage.put('notification-draw-attention', value),
getAudioMessage: () => window.storage.get('audioMessage', false),
setAudioMessage: value => window.storage.put('audioMessage', value),
2021-08-18 20:08:14 +00: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),
getTextFormatting: () => window.storage.get('textFormatting', true),
setTextFormatting: value => window.storage.put('textFormatting', value),
2021-08-18 20:08:14 +00:00
getAlwaysRelayCalls: () => window.storage.get('always-relay-calls'),
setAlwaysRelayCalls: value =>
window.storage.put('always-relay-calls', value),
2023-01-13 00:24:59 +00:00
getAutoLaunch: () => window.IPC.getAutoLaunch(),
2021-08-18 20:08:14 +00:00
setAutoLaunch: async (value: boolean) => {
2023-01-13 00:24:59 +00:00
return window.IPC.setAutoLaunch(value);
2021-08-18 20:08:14 +00:00
},
2023-06-14 22:00:30 +00:00
isFormattingFlagEnabled: () => isEnabled('desktop.textFormatting'),
2021-08-19 01:04:38 +00:00
isPhoneNumberSharingEnabled: () => isPhoneNumberSharingEnabled(),
2021-08-18 20:08:14 +00:00
isPrimary: () => window.textsecure.storage.user.getDeviceId() === 1,
shouldShowStoriesSettings: () => getStoriesAvailable(),
2021-08-18 20:08:14 +00:00
syncRequest: () =>
new Promise<void>((resolve, reject) => {
const FIVE_MINUTES = 5 * durations.MINUTE;
2021-08-18 20:08:14 +00: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
const account = window.ConversationController.getOurConversationOrThrow();
2021-08-18 20:08:14 +00: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);
assertDev(conversation, "Conversation wasn't found");
2021-08-18 20:08:14 +00:00
await conversation.updateLastMessage();
}
},
addDarkOverlay: () => {
2022-11-30 00:53:39 +00:00
const elems = document.querySelectorAll('.dark-overlay');
if (elems.length) {
2021-08-18 20:08:14 +00:00
return;
}
2022-11-30 00:53:39 +00:00
const newOverlay = document.createElement('div');
newOverlay.className = 'dark-overlay';
newOverlay.addEventListener('click', () => {
newOverlay.remove();
});
document.body.prepend(newOverlay);
},
2023-02-27 22:34:43 +00:00
authorizeArtCreator: (data: AuthorizeArtCreatorDataType) => {
// We can get these events even if the user has never linked this instance.
2023-04-11 03:54:43 +00:00
if (!Registration.everDone()) {
2023-02-27 22:34:43 +00:00
log.warn('authorizeArtCreator: Not registered, returning early');
return;
}
window.reduxActions.globalModals.showAuthorizeArtCreator(data);
},
2022-11-30 00:53:39 +00:00
removeDarkOverlay: () => {
const elems = document.querySelectorAll('.dark-overlay');
for (const elem of elems) {
elem.remove();
}
2021-08-18 20:08:14 +00:00
},
2022-12-22 03:07:45 +00:00
showKeyboardShortcuts: () =>
window.reduxActions.globalModals.showShortcutGuideModal(),
2021-08-18 20:08:14 +00:00
deleteAllData: async () => {
2021-08-24 20:57:34 +00:00
renderClearingDataView();
2021-08-18 20:08:14 +00:00
},
showStickerPack: (packId, key) => {
// We can get these events even if the user has never linked this instance.
2023-04-11 03:54:43 +00:00
if (!Registration.everDone()) {
log.warn('showStickerPack: Not registered, returning early');
2021-08-18 20:08:14 +00:00
return;
}
window.reduxActions.globalModals.showStickerPackPreview(packId, key);
2021-08-18 20:08:14 +00:00
},
showGroupViaLink: async hash => {
// We can get these events even if the user has never linked this instance.
2023-04-11 03:54:43 +00:00
if (!Registration.everDone()) {
log.warn('showGroupViaLink: Not registered, returning early');
2021-08-18 20:08:14 +00:00
return;
}
try {
await window.Signal.Groups.joinViaLink(hash);
} catch (error) {
log.error(
2021-08-18 20:08:14 +00:00
'showGroupViaLink: Ran into an error!',
Errors.toLogFormat(error)
2021-08-18 20:08:14 +00:00
);
2022-12-22 03:07:45 +00:00
window.reduxActions.globalModals.showErrorModal({
2023-03-30 00:03:25 +00:00
title: window.i18n('icu:GroupV2--join--general-join-failure--title'),
description: window.i18n('icu:GroupV2--join--general-join-failure'),
2021-08-18 20:08:14 +00:00
});
}
},
2022-10-18 17:12:02 +00:00
async showConversationViaSignalDotMe(hash: string) {
2023-04-11 03:54:43 +00:00
if (!Registration.everDone()) {
log.info(
2021-08-28 13:27:38 +00:00
'showConversationViaSignalDotMe: Not registered, returning early'
);
return;
}
2022-10-18 17:12:02 +00:00
const { showUserNotFoundModal } = window.reduxActions.globalModals;
2021-08-28 13:27:38 +00:00
const maybeE164 = parseE164FromSignalDotMeHash(hash);
if (maybeE164) {
2022-10-18 17:12:02 +00:00
const convoId = await lookupConversationWithoutUuid({
type: 'e164',
2022-08-24 17:33:48 +00:00
e164: maybeE164,
2022-10-18 17:12:02 +00:00
phoneNumber: maybeE164,
showUserNotFoundModal,
setIsFetchingUUID: noop,
});
if (convoId) {
window.reduxActions.conversations.showConversation({
conversationId: convoId,
});
2022-10-18 17:12:02 +00:00
return;
}
// We will show not found modal on error
return;
2022-10-18 17:12:02 +00:00
}
2023-07-20 03:14:08 +00:00
const maybeUsernameBase64 = parseUsernameBase64FromSignalDotMeHash(hash);
if (maybeUsernameBase64) {
const username = await resolveUsernameByLinkBase64(maybeUsernameBase64);
2022-10-18 17:12:02 +00:00
const convoId = await lookupConversationWithoutUuid({
type: 'username',
2023-07-20 03:14:08 +00:00
username,
2022-10-18 17:12:02 +00:00
showUserNotFoundModal,
setIsFetchingUUID: noop,
2022-08-24 17:33:48 +00:00
});
2022-10-18 17:12:02 +00:00
if (convoId) {
window.reduxActions.conversations.showConversation({
conversationId: convoId,
});
2022-08-24 17:33:48 +00:00
return;
}
// We will show not found modal on error
return;
2021-08-28 13:27:38 +00:00
}
log.info('showConversationViaSignalDotMe: invalid E164');
showUnknownSgnlLinkModal();
2021-08-28 13:27:38 +00:00
},
2021-08-18 20:08:14 +00:00
unknownSignalLink: () => {
log.warn('unknownSignalLink: Showing error dialog');
2021-08-28 13:27:38 +00:00
showUnknownSgnlLinkModal();
2021-08-18 20:08:14 +00:00
},
installStickerPack: async (packId, key) => {
void Stickers.downloadStickerPack(packId, key, {
2021-08-18 20:08:14 +00:00
finalStatus: 'installed',
});
},
shutdown: () => Promise.resolve(),
showReleaseNotes: () => {
const { showWhatsNewModal } = window.reduxActions.globalModals;
showWhatsNewModal();
},
2021-08-18 20:08:14 +00:00
2023-01-13 00:24:59 +00:00
getMediaPermissions: window.IPC.getMediaPermissions,
getMediaCameraPermissions: window.IPC.getMediaCameraPermissions,
2021-08-18 20:08:14 +00:00
persistZoomFactor: zoomFactor =>
2021-09-02 23:29:16 +00:00
window.storage.put('zoomFactor', zoomFactor),
2021-08-18 20:08:14 +00:00
...overrideEvents,
};
}
2021-08-28 13:27:38 +00:00
function showUnknownSgnlLinkModal(): void {
2022-12-22 03:07:45 +00:00
window.reduxActions.globalModals.showErrorModal({
2023-03-30 00:03:25 +00:00
description: window.i18n('icu:unknown-sgnl-link'),
2021-08-28 13:27:38 +00:00
});
}