mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 01:15:28 +00:00
merge: branch 'quark/permissions'
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// @ts-expect-error No typings.
|
||||
import stringify from "json-stringify-deterministic";
|
||||
import localforage from "localforage";
|
||||
import { makeAutoObservable, reaction } from "mobx";
|
||||
import { makeAutoObservable, reaction, runInAction } from "mobx";
|
||||
import { Client } from "revolt.js";
|
||||
|
||||
import { reportError } from "../lib/ErrorBoundary";
|
||||
@@ -184,10 +184,12 @@ export default class State {
|
||||
}
|
||||
|
||||
if (Object.keys(obj).length > 0) {
|
||||
client.syncSetSettings(
|
||||
obj as any,
|
||||
revision,
|
||||
);
|
||||
if (client.websocket.connected) {
|
||||
client.syncSetSettings(
|
||||
obj as any,
|
||||
revision,
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -198,12 +200,14 @@ export default class State {
|
||||
}
|
||||
|
||||
this.sync.setRevision(id, revision);
|
||||
client.syncSetSettings(
|
||||
(
|
||||
store as unknown as Syncable
|
||||
).toSyncable(),
|
||||
revision,
|
||||
);
|
||||
if (client.websocket.connected) {
|
||||
client.syncSetSettings(
|
||||
(
|
||||
store as unknown as Syncable
|
||||
).toSyncable(),
|
||||
revision,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,6 +267,26 @@ export default class State {
|
||||
// Post-hydration, init plugins.
|
||||
this.plugins.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset known state values.
|
||||
*/
|
||||
reset() {
|
||||
runInAction(() => {
|
||||
this.draft = new Draft();
|
||||
this.experiments = new Experiments();
|
||||
this.layout = new Layout();
|
||||
this.notifications = new NotificationOptions();
|
||||
this.queue = new MessageQueue();
|
||||
this.settings = new Settings();
|
||||
this.sync = new Sync(this);
|
||||
|
||||
this.save();
|
||||
|
||||
this.persistent = [];
|
||||
this.register();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var state: State;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { runInAction } from "mobx";
|
||||
import { Session } from "revolt-api/types/Auth";
|
||||
import { API } from "revolt.js";
|
||||
|
||||
import { Fonts, MonospaceFonts, Overrides } from "../../context/Theme";
|
||||
|
||||
@@ -58,7 +58,7 @@ export interface LegacySyncOptions {
|
||||
export interface LegacyAuthState {
|
||||
accounts: {
|
||||
[key: string]: {
|
||||
session: Session;
|
||||
session: API.Session;
|
||||
};
|
||||
};
|
||||
active?: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { action, computed, makeAutoObservable, ObservableMap } from "mobx";
|
||||
import { Session } from "revolt-api/types/Auth";
|
||||
import { Nullable } from "revolt.js/dist/util/null";
|
||||
import { API } from "revolt.js";
|
||||
import { Nullable } from "revolt.js";
|
||||
|
||||
import { mapToRecord } from "../../lib/conversion";
|
||||
|
||||
@@ -8,7 +8,7 @@ import Persistent from "../interfaces/Persistent";
|
||||
import Store from "../interfaces/Store";
|
||||
|
||||
interface Account {
|
||||
session: Session;
|
||||
session: API.Session;
|
||||
}
|
||||
|
||||
export interface Data {
|
||||
@@ -82,7 +82,7 @@ export default class Auth implements Store, Persistent<Data> {
|
||||
* Add a new session to the auth manager.
|
||||
* @param session Session
|
||||
*/
|
||||
@action setSession(session: Session) {
|
||||
@action setSession(session: API.Session) {
|
||||
this.sessions.set(session.user_id, { session });
|
||||
this.current = session.user_id;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { action, computed, makeAutoObservable, ObservableMap } from "mobx";
|
||||
import { Presence, RelationshipStatus } from "revolt-api/types/Users";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Message } from "revolt.js/dist/maps/Messages";
|
||||
import { Server } from "revolt.js/dist/maps/Servers";
|
||||
import { Channel } from "revolt.js";
|
||||
import { Message } from "revolt.js";
|
||||
import { Server } from "revolt.js";
|
||||
|
||||
import { mapToRecord } from "../../lib/conversion";
|
||||
|
||||
@@ -113,7 +112,7 @@ export default class NotificationOptions
|
||||
*/
|
||||
shouldNotify(message: Message) {
|
||||
// Make sure the author is not blocked.
|
||||
if (message.author?.relationship === RelationshipStatus.Blocked) {
|
||||
if (message.author?.relationship === "Blocked") {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -124,7 +123,7 @@ export default class NotificationOptions
|
||||
}
|
||||
|
||||
// Check whether we are busy.
|
||||
if (user.status?.presence === Presence.Busy) {
|
||||
if (user.status?.presence === "Busy") {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { action, computed, makeAutoObservable } from "mobx";
|
||||
import { RevoltConfiguration } from "revolt-api/types/Core";
|
||||
import { API } from "revolt.js";
|
||||
import { Client } from "revolt.js";
|
||||
import { Nullable } from "revolt.js/dist/util/null";
|
||||
import { Nullable } from "revolt.js";
|
||||
|
||||
import { isDebug } from "../../revision";
|
||||
import Persistent from "../interfaces/Persistent";
|
||||
@@ -11,9 +11,9 @@ import Store from "../interfaces/Store";
|
||||
* Stores server configuration data.
|
||||
*/
|
||||
export default class ServerConfig
|
||||
implements Store, Persistent<RevoltConfiguration>
|
||||
implements Store, Persistent<API.RevoltConfig>
|
||||
{
|
||||
private config: Nullable<RevoltConfiguration>;
|
||||
private config: Nullable<API.RevoltConfig>;
|
||||
|
||||
/**
|
||||
* Construct new ServerConfig store.
|
||||
@@ -32,7 +32,7 @@ export default class ServerConfig
|
||||
return JSON.parse(JSON.stringify(this.config));
|
||||
}
|
||||
|
||||
@action hydrate(data: RevoltConfiguration) {
|
||||
@action hydrate(data: API.RevoltConfig) {
|
||||
this.config = data ?? null;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ export default class ServerConfig
|
||||
* Set server configuration.
|
||||
* @param config Server configuration
|
||||
*/
|
||||
@action set(config: RevoltConfiguration) {
|
||||
@action set(config: API.RevoltConfig) {
|
||||
this.config = config;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
runInAction,
|
||||
} from "mobx";
|
||||
import { Client } from "revolt.js";
|
||||
import { UserSettings } from "revolt-api/types/Sync";
|
||||
|
||||
import { mapToRecord } from "../../lib/conversion";
|
||||
|
||||
@@ -104,7 +103,7 @@ export default class Sync implements Store, Persistent<Data> {
|
||||
return this.revision.get(key);
|
||||
}
|
||||
|
||||
@action apply(data: UserSettings) {
|
||||
@action apply(data: Record<string, [number, string]>) {
|
||||
const tryRead = (key: string) => {
|
||||
if (key in data) {
|
||||
const revision = data[key][0];
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-expect-error No typings.
|
||||
import rgba from "color-rgba";
|
||||
import { makeAutoObservable, computed, action } from "mobx";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user