diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-03-15 15:05:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-15 15:05:13 -0500 |
commit | 3c05a08482cbcff452ece8c11ff3a2a740c79503 (patch) | |
tree | da6458cb8238b1537372c66ffb63d46d9f2ecae6 /src/state/models/log.ts | |
parent | 94741cddedaa9c923f37b7cc11d5a2cbab81ca44 (diff) | |
download | voidsky-3c05a08482cbcff452ece8c11ff3a2a740c79503.tar.zst |
Logout bug hunt (#294)
* Stop storing the log on disk * Add more info to the session logging * Only clear session tokens from storage when they've expired * Retry session resumption a few times if it's a network issue * Improvements to the 'connecting' screen
Diffstat (limited to 'src/state/models/log.ts')
-rw-r--r-- | src/state/models/log.ts | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/state/models/log.ts b/src/state/models/log.ts index f2709f2f1..ed701dc61 100644 --- a/src/state/models/log.ts +++ b/src/state/models/log.ts @@ -1,6 +1,7 @@ import {makeAutoObservable} from 'mobx' import {XRPCError, XRPCInvalidResponseError} from '@atproto/xrpc' -import {isObj, hasProp} from 'lib/type-guards' + +const MAX_ENTRIES = 300 interface LogEntry { id: string @@ -28,27 +29,14 @@ export class LogModel { entries: LogEntry[] = [] constructor() { - makeAutoObservable(this, {serialize: false, hydrate: false}) - } - - serialize(): unknown { - return { - entries: this.entries.slice(-100), - } - } - - hydrate(v: unknown) { - if (isObj(v)) { - if (hasProp(v, 'entries') && Array.isArray(v.entries)) { - this.entries = v.entries.filter( - e => isObj(e) && hasProp(e, 'id') && typeof e.id === 'string', - ) - } - } + makeAutoObservable(this) } private add(entry: LogEntry) { this.entries.push(entry) + while (this.entries.length > MAX_ENTRIES) { + this.entries = this.entries.slice(50) + } } debug(summary: string, details?: any) { |