Files
kandev/apps/web/components/task/task-session-sidebar-grouped-view.ts
T
João Salavisa d54c2effef fix(i18n): address #2249 review findings (#2279)
Co-authored-by: Kandev Agent <agent@kandev.dev>
2026-08-05 14:39:01 +02:00

36 lines
1.2 KiB
TypeScript

"use client";
import { useMemo } from "react";
import { useTranslation } from "react-i18next";
import { applyView } from "@/lib/sidebar/apply-view";
import { useEffectiveSidebarView } from "@/hooks/domains/sidebar/use-effective-sidebar-view";
import { useSidebarTaskPrefs } from "@/hooks/domains/sidebar/use-sidebar-task-prefs";
import type { TaskSwitcherItem } from "./task-switcher";
export function useGroupedSidebarView(displayTasks: TaskSwitcherItem[]) {
const prefs = useSidebarTaskPrefs();
const effectiveView = useEffectiveSidebarView();
const { pinnedTaskIds, orderedTaskIds, subtaskOrderByParentId } = prefs;
// `applyGroup`'s executorType label comes from `getExecutorLabel`, which reads
// the catalog. Without the language in the deps the group heading keeps the
// previous locale until task data changes.
const { i18n } = useTranslation();
const grouped = useMemo(
() =>
applyView(displayTasks, effectiveView, {
pinnedTaskIds,
orderedTaskIds,
subtaskOrderByParentId,
}),
[
displayTasks,
effectiveView,
pinnedTaskIds,
orderedTaskIds,
subtaskOrderByParentId,
i18n.language,
],
);
return { grouped, effectiveView, prefs };
}