forked from abner/for-legacy-web
chore(mobx): add legacy redux migations
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { mapToRecord } from "../../lib/conversion";
|
||||
import Persistent from "../interfaces/Persistent";
|
||||
import Store from "../interfaces/Store";
|
||||
|
||||
interface Data {
|
||||
export interface Data {
|
||||
drafts: Record<string, string>;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ export const EXPERIMENTS: {
|
||||
},
|
||||
};
|
||||
|
||||
interface Data {
|
||||
export interface Data {
|
||||
enabled?: Experiment[];
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { mapToRecord } from "../../lib/conversion";
|
||||
import Persistent from "../interfaces/Persistent";
|
||||
import Store from "../interfaces/Store";
|
||||
|
||||
interface Data {
|
||||
export interface Data {
|
||||
lastSection?: "home" | "server";
|
||||
lastHomePath?: string;
|
||||
lastOpened?: Record<string, string>;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Language, Languages } from "../../context/Locale";
|
||||
import Persistent from "../interfaces/Persistent";
|
||||
import Store from "../interfaces/Store";
|
||||
|
||||
interface Data {
|
||||
export interface Data {
|
||||
lang: Language;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ export const DEFAULT_STATES: {
|
||||
*/
|
||||
export const DEFAULT_SERVER_STATE: NotificationState = "mention";
|
||||
|
||||
interface Data {
|
||||
export interface Data {
|
||||
server?: Record<string, NotificationState>;
|
||||
channel?: Record<string, NotificationState>;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,6 @@ import { Nullable } from "revolt.js/dist/util/null";
|
||||
import Persistent from "../interfaces/Persistent";
|
||||
import Store from "../interfaces/Store";
|
||||
|
||||
interface Data {
|
||||
config?: RevoltConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores server configuration data.
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@ import SAudio, { SoundOptions } from "./helpers/SAudio";
|
||||
import SSecurity from "./helpers/SSecurity";
|
||||
import STheme from "./helpers/STheme";
|
||||
|
||||
interface ISettings {
|
||||
export interface ISettings {
|
||||
"notifications:desktop": boolean;
|
||||
"notifications:sounds": SoundOptions;
|
||||
|
||||
@@ -60,8 +60,9 @@ export default class Settings implements Store, Persistent<ISettings> {
|
||||
}
|
||||
|
||||
@action hydrate(data: ISettings) {
|
||||
Object.keys(data).forEach((key) =>
|
||||
this.data.set(key, (data as any)[key]),
|
||||
Object.keys(data).forEach(
|
||||
(key) =>
|
||||
(data as any)[key] && this.data.set(key, (data as any)[key]),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export const SYNC_KEYS: SyncKeys[] = [
|
||||
"notifications",
|
||||
];
|
||||
|
||||
interface Data {
|
||||
export interface Data {
|
||||
disabled: SyncKeys[];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user