PNP Settings
This commit is contained in:
parent
5bcf71ef2c
commit
5d110964b9
27 changed files with 562 additions and 149 deletions
|
@ -28,7 +28,7 @@ import { renderClearingDataView } from '../shims/renderClearingDataView';
|
|||
import * as universalExpireTimer from './universalExpireTimer';
|
||||
import { PhoneNumberDiscoverability } from './phoneNumberDiscoverability';
|
||||
import { PhoneNumberSharingMode } from './phoneNumberSharingMode';
|
||||
import { assertDev } from './assert';
|
||||
import { strictAssert, assertDev } from './assert';
|
||||
import * as durations from './durations';
|
||||
import type { DurationInSeconds } from './durations';
|
||||
import { isPhoneNumberSharingEnabled } from './isPhoneNumberSharingEnabled';
|
||||
|
@ -136,8 +136,6 @@ type ValuesWithSetters = Omit<
|
|||
| 'blockedCount'
|
||||
| 'defaultConversationColor'
|
||||
| 'linkPreviewSetting'
|
||||
| 'phoneNumberDiscoverabilitySetting'
|
||||
| 'phoneNumberSharingSetting'
|
||||
| 'readReceiptSetting'
|
||||
| 'typingIndicatorSetting'
|
||||
| 'deviceName'
|
||||
|
@ -177,6 +175,18 @@ export type IPCEventsType = IPCEventsGettersType &
|
|||
export function createIPCEvents(
|
||||
overrideEvents: Partial<IPCEventsType> = {}
|
||||
): IPCEventsType {
|
||||
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');
|
||||
};
|
||||
|
||||
return {
|
||||
getDeviceName: () => window.textsecure.storage.user.getDeviceName(),
|
||||
|
||||
|
@ -185,6 +195,22 @@ export function createIPCEvents(
|
|||
webFrame.setZoomFactor(zoomFactor);
|
||||
},
|
||||
|
||||
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) => {
|
||||
|
@ -202,6 +228,8 @@ export function createIPCEvents(
|
|||
},
|
||||
setStoryViewReceiptsEnabled: async (value: boolean) => {
|
||||
await window.storage.put('storyViewReceiptsEnabled', value);
|
||||
const account = window.ConversationController.getOurConversationOrThrow();
|
||||
account.captureChange('storyViewReceiptsEnabled');
|
||||
},
|
||||
|
||||
getPreferredAudioInputDevice: () =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue