Change Phone Number notifications
This commit is contained in:
parent
4b82ac387b
commit
a001882d58
17 changed files with 277 additions and 39 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue