Reduce idle timer updates and stabilize toolbox normalization
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s
This commit is contained in:
parent
cce3f3c7f8
commit
c096cc07fe
3 changed files with 10 additions and 4 deletions
|
|
@ -146,7 +146,8 @@ function getToneFromDelta(value) {
|
|||
}
|
||||
|
||||
export function RngSimulatorModule({ toolboxId, moduleId, context, editing = false, setEditing = () => {}, textExchangeOpen }) {
|
||||
const data = context.normalizeRngSimulatorData(context.getModuleData(toolboxId, moduleId, {}));
|
||||
const rawData = context.getModuleData(toolboxId, moduleId, {});
|
||||
const data = useMemo(() => context.normalizeRngSimulatorData(rawData), [context, rawData]);
|
||||
const textContent = context.moduleText?.rngSimulator || {};
|
||||
const tabs = useMemo(() => [
|
||||
{ ...RNG_TABS[0], label: textContent.trackingTabLabel || RNG_TABS[0].label },
|
||||
|
|
|
|||
|
|
@ -31,16 +31,20 @@ import {
|
|||
} from "./timerOptions.js";
|
||||
|
||||
export function TimerModule({ toolboxId, moduleId, context, textExchangeOpen }) {
|
||||
const data = context.normalizeTimerData(context.getModuleData(toolboxId, moduleId, { activeTab: "stopwatch" }));
|
||||
const rawData = context.getModuleData(toolboxId, moduleId, { activeTab: "stopwatch" });
|
||||
const data = useMemo(() => context.normalizeTimerData(rawData), [context, rawData]);
|
||||
const textContent = context.moduleText?.timer || {};
|
||||
const activeTab = data.activeTab;
|
||||
const [nowMs, setNowMs] = useState(getNowMs);
|
||||
const countdownDraft = useDraftForm(DEFAULT_COUNTDOWN_FORM);
|
||||
|
||||
const clockActive = Boolean(data.stopwatch.startedAt || data.countdowns.some((countdown) => countdown.autoRefresh));
|
||||
|
||||
useEffect(() => {
|
||||
if (!clockActive) return undefined;
|
||||
const intervalId = window.setInterval(() => setNowMs(getNowMs()), 50);
|
||||
return () => window.clearInterval(intervalId);
|
||||
}, []);
|
||||
}, [clockActive]);
|
||||
|
||||
const stopwatchElapsedMs = data.stopwatch.startedAt
|
||||
? data.stopwatch.elapsedMs + Math.max(0, nowMs - data.stopwatch.startedAt)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ import {
|
|||
} from "./goalTreeUtils.js";
|
||||
|
||||
export function useGoalTreeController({ toolboxId, moduleId, context, editing, setEditing, openEditor }) {
|
||||
const data = context.normalizeGoalTreeData(context.getModuleData(toolboxId, moduleId, { nodes: [] }));
|
||||
const rawData = context.getModuleData(toolboxId, moduleId, { nodes: [] });
|
||||
const data = useMemo(() => context.normalizeGoalTreeData(rawData), [context, rawData]);
|
||||
const textContent = context.moduleText?.goalTree || {};
|
||||
const treeOrientation = data.orientation || "horizontal";
|
||||
const verticalView = treeOrientation === "vertical";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue