fix(snjs): notify http service of refresh session
This commit is contained in:
@@ -22,6 +22,10 @@ import {
|
||||
UNSUPPORTED_KEY_DERIVATION,
|
||||
UNSUPPORTED_PROTOCOL_VERSION,
|
||||
Challenge,
|
||||
InternalEventHandlerInterface,
|
||||
InternalEventInterface,
|
||||
ApiServiceEvent,
|
||||
SessionRefreshedData,
|
||||
} from '@standardnotes/services'
|
||||
import { Base64String } from '@standardnotes/sncrypto-common'
|
||||
import { ClientDisplayableError, SessionBody } from '@standardnotes/responses'
|
||||
@@ -67,7 +71,10 @@ export enum SessionEvent {
|
||||
* server credentials, such as the session token. It also exposes methods for registering
|
||||
* for a new account, signing into an existing one, or changing an account password.
|
||||
*/
|
||||
export class SNSessionManager extends AbstractService<SessionEvent> implements SessionsClientInterface {
|
||||
export class SNSessionManager
|
||||
extends AbstractService<SessionEvent>
|
||||
implements SessionsClientInterface, InternalEventHandlerInterface
|
||||
{
|
||||
private user?: Responses.User
|
||||
private isSessionRenewChallengePresented = false
|
||||
|
||||
@@ -94,6 +101,12 @@ export class SNSessionManager extends AbstractService<SessionEvent> implements S
|
||||
})
|
||||
}
|
||||
|
||||
async handleEvent(event: InternalEventInterface): Promise<void> {
|
||||
if (event.type === ApiServiceEvent.SessionRefreshed) {
|
||||
this.httpService.setSession((event.payload as SessionRefreshedData).session)
|
||||
}
|
||||
}
|
||||
|
||||
override deinit(): void {
|
||||
;(this.protocolService as unknown) = undefined
|
||||
;(this.diskStorageService as unknown) = undefined
|
||||
|
||||
Reference in New Issue
Block a user