chore(mobx): add legacy redux migations

This commit is contained in:
Paul
2021-12-21 12:31:14 +00:00
parent 961ba0dedb
commit b80e02cfaf
10 changed files with 99 additions and 16 deletions

View File

@@ -2,6 +2,8 @@ import { action, computed, makeAutoObservable, ObservableMap } from "mobx";
import { Session } from "revolt-api/types/Auth";
import { Nullable } from "revolt.js/dist/util/null";
import { mapToRecord } from "../../lib/conversion";
import Persistent from "../interfaces/Persistent";
import Store from "../interfaces/Store";
@@ -9,8 +11,8 @@ interface Account {
session: Session;
}
interface Data {
sessions: Record<string, Account> | [string, Account][];
export interface Data {
sessions: Record<string, Account>;
current?: string;
}
@@ -37,7 +39,7 @@ export default class Auth implements Store, Persistent<Data> {
@action toJSON() {
return {
sessions: JSON.parse(JSON.stringify(this.sessions)),
sessions: JSON.parse(JSON.stringify(mapToRecord(this.sessions))),
current: this.current ?? undefined,
};
}