Refresh PNI on startup
This commit is contained in:
parent
a4cf2e0948
commit
5c2016ec40
7 changed files with 90 additions and 75 deletions
28
ts/util/updateOurUsernameAndPni.ts
Normal file
28
ts/util/updateOurUsernameAndPni.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2021-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { strictAssert } from './assert';
|
||||
import { dropNull } from './dropNull';
|
||||
|
||||
export async function updateOurUsernameAndPni(): Promise<void> {
|
||||
const { server } = window.textsecure;
|
||||
|
||||
strictAssert(
|
||||
server,
|
||||
'updateOurUsernameAndPni: window.textsecure.server not available'
|
||||
);
|
||||
|
||||
const me = window.ConversationController.getOurConversationOrThrow();
|
||||
const { username, pni } = await server.whoami();
|
||||
|
||||
me.set({ username: dropNull(username) });
|
||||
window.Signal.Data.updateConversation(me.attributes);
|
||||
|
||||
const manager = window.getAccountManager();
|
||||
strictAssert(
|
||||
manager,
|
||||
'updateOurUsernameAndPni: AccountManager not available'
|
||||
);
|
||||
|
||||
await manager.setPni(pni);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue