fix(core): allow storage reset to be async
This commit is contained in:
parent
f4ab514b18
commit
c538c2b059
3 changed files with 4 additions and 4 deletions
|
@ -21,7 +21,7 @@ export async function logOut(client: BaseTelegramClient): Promise<true> {
|
||||||
|
|
||||||
client.emit('logged_out')
|
client.emit('logged_out')
|
||||||
|
|
||||||
client.storage.reset()
|
await client.storage.reset()
|
||||||
await client.saveStorage()
|
await client.saveStorage()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -82,7 +82,7 @@ export interface ITelegramStorage {
|
||||||
*
|
*
|
||||||
* @param [withAuthKeys=false] Whether to also reset auth keys
|
* @param [withAuthKeys=false] Whether to also reset auth keys
|
||||||
*/
|
*/
|
||||||
reset(withAuthKeys?: boolean): void
|
reset(withAuthKeys?: boolean): MaybeAsync<void>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set default datacenter to use with this session.
|
* Set default datacenter to use with this session.
|
||||||
|
|
|
@ -160,7 +160,7 @@ export function testStorage<T extends ITelegramStorage>(
|
||||||
it('should not reset auth keys on reset()', async () => {
|
it('should not reset auth keys on reset()', async () => {
|
||||||
await s.setAuthKeyFor(2, key2)
|
await s.setAuthKeyFor(2, key2)
|
||||||
await s.setAuthKeyFor(3, key3)
|
await s.setAuthKeyFor(3, key3)
|
||||||
s.reset()
|
await s.reset()
|
||||||
|
|
||||||
expect(maybeHexEncode(await s.getAuthKeyFor(2))).toEqual(hexEncode(key2))
|
expect(maybeHexEncode(await s.getAuthKeyFor(2))).toEqual(hexEncode(key2))
|
||||||
expect(maybeHexEncode(await s.getAuthKeyFor(3))).toEqual(hexEncode(key3))
|
expect(maybeHexEncode(await s.getAuthKeyFor(3))).toEqual(hexEncode(key3))
|
||||||
|
@ -169,7 +169,7 @@ export function testStorage<T extends ITelegramStorage>(
|
||||||
it('should reset auth keys on reset(true)', async () => {
|
it('should reset auth keys on reset(true)', async () => {
|
||||||
await s.setAuthKeyFor(2, key2)
|
await s.setAuthKeyFor(2, key2)
|
||||||
await s.setAuthKeyFor(3, key3)
|
await s.setAuthKeyFor(3, key3)
|
||||||
s.reset(true)
|
await s.reset(true)
|
||||||
|
|
||||||
expect(await s.getAuthKeyFor(2)).toBeNull()
|
expect(await s.getAuthKeyFor(2)).toBeNull()
|
||||||
expect(await s.getAuthKeyFor(3)).toBeNull()
|
expect(await s.getAuthKeyFor(3)).toBeNull()
|
||||||
|
|
Loading…
Reference in a new issue