mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 12:19:41 +00:00
Change Phone Number notifications
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
import { WebAPICredentials } from '../Types.d';
|
||||
|
||||
import { strictAssert } from '../../util/assert';
|
||||
import { StorageInterface } from '../../types/Storage.d';
|
||||
|
||||
import Helpers from '../Helpers';
|
||||
@@ -27,6 +28,25 @@ export class User {
|
||||
window.log.info('storage.user: uuid and device id changed');
|
||||
}
|
||||
|
||||
public async setNumber(number: string): Promise<void> {
|
||||
if (this.getNumber() === number) {
|
||||
return;
|
||||
}
|
||||
|
||||
const deviceId = this.getDeviceId();
|
||||
strictAssert(
|
||||
deviceId !== undefined,
|
||||
'Cannot update device number without knowing device id'
|
||||
);
|
||||
|
||||
window.log.info('storage.user: number changed');
|
||||
|
||||
await this.storage.put('number_id', `${number}.${deviceId}`);
|
||||
|
||||
// Notify redux about phone number change
|
||||
window.Whisper.events.trigger('userChanged');
|
||||
}
|
||||
|
||||
public getNumber(): string | undefined {
|
||||
const numberId = this.storage.get('number_id');
|
||||
if (numberId === undefined) return undefined;
|
||||
|
||||
Reference in New Issue
Block a user