Create unified architecture for memo statistics, filters, and sorting across all pages (Home, Explore, Archived, Profile) with proper visibility filtering and consistent data flow. Key changes: - Rename HomeLayout → MainLayout to reflect broader usage - Create useFilteredMemoStats hook for unified stats computation - Create useMemoFilters/useMemoSorting hooks to eliminate duplication - Refactor all pages to use unified hooks (~147 lines removed) - Move Explore route under MainLayout (was sibling before) - Fix masonry column calculation threshold (1024px → 688px+) Architecture improvements: - MainLayout computes filter/stats per route context - Stats/tags based on same filter as memo list (consistency) - Proper visibility filtering (PUBLIC/PROTECTED) on Explore - MemoExplorer/StatisticsView accept stats as required props - Eliminated optional fallbacks and redundant data fetching Benefits: - Single source of truth for stats computation - Stats remain static (don't change with user filters) - Reduced code duplication across 4 pages - Better maintainability and type safety - Proper security (no private memo leakage on Explore) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { observer } from "mobx-react-lite";
|
|
import { MemoRenderContext } from "@/components/MasonryView";
|
|
import MemoView from "@/components/MemoView";
|
|
import PagedMemoList from "@/components/PagedMemoList";
|
|
import { useMemoFilters, useMemoSorting } from "@/hooks";
|
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
|
import { State } from "@/types/proto/api/v1/common";
|
|
import { Memo } from "@/types/proto/api/v1/memo_service";
|
|
|
|
const Archived = observer(() => {
|
|
const user = useCurrentUser();
|
|
|
|
// Build filter using unified hook (no shortcuts or pinned filter)
|
|
const memoFilter = useMemoFilters({
|
|
creatorName: user.name,
|
|
includeShortcuts: false,
|
|
includePinned: false,
|
|
});
|
|
|
|
// Get sorting logic using unified hook (pinned first, archived state)
|
|
const { listSort, orderBy } = useMemoSorting({
|
|
pinnedFirst: true,
|
|
state: State.ARCHIVED,
|
|
});
|
|
|
|
return (
|
|
<PagedMemoList
|
|
renderer={(memo: Memo, context?: MemoRenderContext) => (
|
|
<MemoView key={`${memo.name}-${memo.updateTime}`} memo={memo} showVisibility compact={context?.compact} />
|
|
)}
|
|
listSort={listSort}
|
|
state={State.ARCHIVED}
|
|
orderBy={orderBy}
|
|
filter={memoFilter}
|
|
/>
|
|
);
|
|
});
|
|
|
|
export default Archived;
|