Fix accountRecord.e164 deprecation
This commit is contained in:
parent
7b62576def
commit
337d3f8490
3 changed files with 34 additions and 17 deletions
|
@ -24,7 +24,7 @@ import {
|
|||
PhoneNumberDiscoverability,
|
||||
parsePhoneNumberDiscoverability,
|
||||
} from '../util/phoneNumberDiscoverability';
|
||||
import { isPnpEnabled } from '../util/isPnpEnabled';
|
||||
import { isPnpCapable } from '../util/isPnpCapable';
|
||||
import { arePinnedConversationsEqual } from '../util/arePinnedConversationsEqual';
|
||||
import type { ConversationModel } from '../models/conversations';
|
||||
import {
|
||||
|
@ -281,7 +281,10 @@ export function toAccountRecord(
|
|||
}
|
||||
|
||||
const accountE164 = window.storage.get('accountE164');
|
||||
if (accountE164 !== undefined) {
|
||||
// Once account becomes PNP capable - we want to stop populating this field
|
||||
// because it is deprecated in PNP world and we don't want to cause storage
|
||||
// service thrashing.
|
||||
if (accountE164 !== undefined && !isPnpCapable()) {
|
||||
accountRecord.e164 = accountE164;
|
||||
}
|
||||
|
||||
|
@ -1234,15 +1237,13 @@ export async function mergeAccountRecord(
|
|||
await window.storage.put('primarySendsSms', primarySendsSms);
|
||||
}
|
||||
|
||||
// Store AccountRecord.e164 in an auxiliary field that isn't used for any
|
||||
// other purpose in the app. This is required only while we are deprecating
|
||||
// the AccountRecord.e164.
|
||||
if (typeof accountE164 === 'string') {
|
||||
await window.storage.put('accountE164', accountE164);
|
||||
if (
|
||||
!RemoteConfig.isEnabled('desktop.pnp') &&
|
||||
!RemoteConfig.isEnabled('desktop.pnp.accountE164Deprecation') &&
|
||||
!isPnpEnabled()
|
||||
) {
|
||||
await window.storage.user.setNumber(accountE164);
|
||||
}
|
||||
} else {
|
||||
await window.storage.remove('accountE164');
|
||||
}
|
||||
|
||||
if (preferredReactionEmoji.canBeSynced(rawPreferredReactionEmoji)) {
|
||||
|
|
24
ts/util/isPnpCapable.ts
Normal file
24
ts/util/isPnpCapable.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import * as log from '../logging/log';
|
||||
|
||||
export function isPnpCapable(): boolean {
|
||||
const me = window.ConversationController.getOurConversation();
|
||||
if (!me) {
|
||||
log.warn('isPnpCapable: missing our conversation');
|
||||
return false;
|
||||
}
|
||||
|
||||
// These capabilities are filled by a periodic background check for our
|
||||
// account.
|
||||
const capabilities = me.get('capabilities');
|
||||
if (!capabilities) {
|
||||
log.warn('isPnpCapable: no cached capabilities');
|
||||
return false;
|
||||
}
|
||||
|
||||
// `capabilities.pni` becomes true once all linked devices and the primary
|
||||
// advertise this capability.
|
||||
return capabilities.pni === true;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { isStaging } from './version';
|
||||
|
||||
export function isPnpEnabled(version = window.getVersion()): boolean {
|
||||
return isStaging(version);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue