a3d1dce2ca
Reverts21a042d,0d3e92c,0016b6a,c797e98,03ebea1. Keeps the pet's own-sessions scope, status bar mine=1, scroll speed and the health hover card. The chat_* tables and <data dir>/chat/ files are left in place (unused).
30 lines
975 B
TypeScript
30 lines
975 B
TypeScript
/**
|
|
* @file SagiMount.tsx
|
|
* @description Gate for the Sagi mascot: follows the enabled preference
|
|
* (`useSagiEnabled`) and only while it is on lazy-loads and mounts `Sagi` — so
|
|
* a disabled mascot costs no chunk download, no brain, no 1 Hz tick and no
|
|
* WebSocket reducer.
|
|
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
|
*/
|
|
|
|
import { lazy, Suspense, useEffect, useState } from "react";
|
|
import { sagiPrefs } from "./prefs";
|
|
|
|
const Sagi = lazy(() => import("./Sagi").then((m) => ({ default: m.Sagi })));
|
|
|
|
/** The mascot's enabled preference, followed live (Settings, other tabs). */
|
|
export function useSagiEnabled(): boolean {
|
|
const [enabled, setEnabled] = useState(() => sagiPrefs.getEnabled());
|
|
useEffect(() => sagiPrefs.subscribe(() => setEnabled(sagiPrefs.getEnabled())), []);
|
|
return enabled;
|
|
}
|
|
|
|
export function SagiMount() {
|
|
if (!useSagiEnabled()) return null;
|
|
return (
|
|
<Suspense fallback={null}>
|
|
<Sagi />
|
|
</Suspense>
|
|
);
|
|
}
|