mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 01:15:28 +00:00
fix(mobx): properly persist login state
This commit is contained in:
@@ -11,6 +11,7 @@ import Locale from "./Locale";
|
||||
import Theme from "./Theme";
|
||||
import Intermediate from "./intermediate/Intermediate";
|
||||
import Client from "./revoltjs/RevoltClient";
|
||||
import SyncManager from "./revoltjs/SyncManager";
|
||||
|
||||
/**
|
||||
* This component provides all of the application's context layers.
|
||||
@@ -29,7 +30,10 @@ export default function Context({ children }: { children: Children }) {
|
||||
<Router basename={import.meta.env.BASE_URL}>
|
||||
<Locale>
|
||||
<Intermediate>
|
||||
<Client>{children}</Client>
|
||||
<Client>
|
||||
{children}
|
||||
<SyncManager />
|
||||
</Client>
|
||||
</Intermediate>
|
||||
</Locale>
|
||||
<Theme />
|
||||
|
||||
@@ -15,7 +15,9 @@ export default function SyncManager() {
|
||||
|
||||
// Sync settings from Revolt.
|
||||
useEffect(() => {
|
||||
state.sync.pull(client);
|
||||
if (client) {
|
||||
state.sync.pull(client);
|
||||
}
|
||||
}, [client]);
|
||||
|
||||
// Keep data synced.
|
||||
@@ -23,6 +25,7 @@ export default function SyncManager() {
|
||||
|
||||
// Take data updates from Revolt.
|
||||
useEffect(() => {
|
||||
if (!client) return;
|
||||
function onPacket(packet: ClientboundNotification) {
|
||||
if (packet.type === "UserSettingsUpdate") {
|
||||
state.sync.apply(packet.update);
|
||||
|
||||
Reference in New Issue
Block a user