Add planner-aware memos and unified tool configuration panels
All checks were successful
Deploy Sokko G / deploy (push) Successful in 18s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 18s
This commit is contained in:
parent
acd9b2fe11
commit
808610dcf2
53 changed files with 842 additions and 329 deletions
|
|
@ -1,7 +1,8 @@
|
|||
// Rôle : affiche en bas de page les mémos actifs de la toolbox courante ou liée au jeu.
|
||||
import { useMemo } from "react";
|
||||
// Rôle : affiche en bas de page les mémos et alertes de tâches de la toolbox courante ou liée au jeu.
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { moduleStorageKey, normalizeMemosData } from "./storage/toolboxStorage.js";
|
||||
import { MemosTicker } from "./modules/MemosTicker.jsx";
|
||||
import { getPlannerTaskTickerItems, resolveMemosPlannerLink } from "./modules/memosPlannerUtils.js";
|
||||
|
||||
function getRouteToolboxId(route, links) {
|
||||
const toolboxMatch = route.match(/^\/toolbox\/([^/]+)/);
|
||||
|
|
@ -11,6 +12,13 @@ function getRouteToolboxId(route, links) {
|
|||
}
|
||||
|
||||
export function GlobalMemosTicker({ route, toolboxes, links, moduleData, textContent }) {
|
||||
const [nowMs, setNowMs] = useState(() => Date.now());
|
||||
|
||||
useEffect(() => {
|
||||
const intervalId = window.setInterval(() => setNowMs(Date.now()), 60000);
|
||||
return () => window.clearInterval(intervalId);
|
||||
}, []);
|
||||
|
||||
const items = useMemo(() => {
|
||||
const toolboxId = getRouteToolboxId(route, links);
|
||||
const toolbox = toolboxes.find((item) => item.id === toolboxId);
|
||||
|
|
@ -20,9 +28,20 @@ export function GlobalMemosTicker({ route, toolboxes, links, moduleData, textCon
|
|||
.flatMap((module) => {
|
||||
const data = normalizeMemosData(moduleData[moduleStorageKey(toolbox.id, module.id)]);
|
||||
if (!data.tickerEnabled) return [];
|
||||
return data.items.map((memo) => ({ ...memo, id: `${module.id}:${memo.id}` }));
|
||||
const plannerLink = resolveMemosPlannerLink(data.plannerLink, toolbox.modules);
|
||||
const taskItems = getPlannerTaskTickerItems({
|
||||
plannerLink,
|
||||
modules: toolbox.modules,
|
||||
getPlannerData: (plannerId) => moduleData[moduleStorageKey(toolbox.id, plannerId)],
|
||||
nowMs,
|
||||
alertTemplate: textContent?.taskAlertTemplate
|
||||
});
|
||||
return [
|
||||
...data.items.map((memo) => ({ ...memo, id: `${module.id}:${memo.id}` })),
|
||||
...taskItems.map((item) => ({ ...item, id: `${module.id}:${item.id}` }))
|
||||
];
|
||||
});
|
||||
}, [route, toolboxes, links, moduleData]);
|
||||
}, [route, toolboxes, links, moduleData, nowMs, textContent?.taskAlertTemplate]);
|
||||
|
||||
if (!items.length) return null;
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue