From 55d8e6ad4291c2a54756d7a0e6495955a16ab38a Mon Sep 17 00:00:00 2001 From: johnnyjoygh Date: Sat, 5 Sep 2026 00:22:05 +0800 Subject: [PATCH] chore(web): compact user profile header and in-place views on profiles The user page at /u/:username now opens with a compact identity block (40px avatar, name, handle, clamped bio) instead of a hero header with a share button, and the list beneath it follows the user's column setting like Explore does. In grid mode the header spans every column via a new ColumnGrid header slot, exposed through PagedMemoList.renderHeader. Loading shows a skeleton after the standard delay, not-found renders a body instead of a toast fired from render, and visitors get an explicit empty message. Saved views now apply on profile routes too. A single profile-route matcher in lib/memo-views replaces five separate spellings, isMemoCollectionRoute names the routes where views, calendar days and tags narrow the list in place, and the sidebar shows the Views section on every such route for signed-in users. The never-taken navigation-target branch in the collection sidebar is removed along with its props. --- web/src/components/AppSidebar/AppSidebar.tsx | 22 +-- .../components/AppSidebar/QuickFindDialog.tsx | 4 +- web/src/components/AppSidebar/TagsSection.tsx | 17 +- .../components/AppSidebar/ViewsSection.tsx | 4 +- web/src/components/AppSidebar/routes.ts | 4 +- web/src/components/ColumnGrid/ColumnGrid.tsx | 32 +++- web/src/components/MemoFilters.tsx | 4 +- web/src/components/MemoView/navigation.ts | 4 +- .../PagedMemoList/PagedMemoList.tsx | 9 +- .../StatisticsView/StatisticsView.tsx | 4 +- web/src/hooks/useDateFilterNavigation.ts | 12 +- web/src/lib/memo-views.ts | 23 ++- web/src/locales/ar.json | 3 +- web/src/locales/bg.json | 3 +- web/src/locales/ca.json | 3 +- web/src/locales/cs.json | 3 +- web/src/locales/da.json | 3 +- web/src/locales/de.json | 3 +- web/src/locales/el.json | 3 +- web/src/locales/en-GB.json | 3 +- web/src/locales/en.json | 8 +- web/src/locales/es.json | 3 +- web/src/locales/et.json | 3 +- web/src/locales/fa.json | 3 +- web/src/locales/fi.json | 3 +- web/src/locales/fr.json | 3 +- web/src/locales/gl.json | 3 +- web/src/locales/he.json | 3 +- web/src/locales/hi.json | 3 +- web/src/locales/hr.json | 3 +- web/src/locales/hu.json | 3 +- web/src/locales/id.json | 3 +- web/src/locales/it.json | 3 +- web/src/locales/ja.json | 3 +- web/src/locales/ka-GE.json | 3 +- web/src/locales/ko.json | 3 +- web/src/locales/lt.json | 3 +- web/src/locales/lv.json | 3 +- web/src/locales/mr.json | 3 +- web/src/locales/nb.json | 3 +- web/src/locales/nl.json | 3 +- web/src/locales/pl.json | 3 +- web/src/locales/pt-BR.json | 3 +- web/src/locales/pt-PT.json | 3 +- web/src/locales/ro.json | 3 +- web/src/locales/ru.json | 3 +- web/src/locales/sk.json | 3 +- web/src/locales/sl.json | 3 +- web/src/locales/sr.json | 3 +- web/src/locales/sv.json | 3 +- web/src/locales/th.json | 3 +- web/src/locales/tr.json | 3 +- web/src/locales/uk.json | 3 +- web/src/locales/vi.json | 3 +- web/src/locales/zh-Hans.json | 3 +- web/src/locales/zh-Hant.json | 3 +- web/src/pages/UserProfile.tsx | 166 ++++++++++-------- web/src/router/index.tsx | 2 +- web/src/router/routes.ts | 1 + web/tests/column-grid.test.tsx | 25 +++ web/tests/memo-views.test.ts | 14 ++ web/tests/sidebar-row-state.test.tsx | 7 +- 62 files changed, 274 insertions(+), 217 deletions(-) diff --git a/web/src/components/AppSidebar/AppSidebar.tsx b/web/src/components/AppSidebar/AppSidebar.tsx index b21e4281..ea83ef78 100644 --- a/web/src/components/AppSidebar/AppSidebar.tsx +++ b/web/src/components/AppSidebar/AppSidebar.tsx @@ -42,7 +42,8 @@ import useCurrentUser from "@/hooks/useCurrentUser"; import { type MemoStatsContext, useFilteredMemoStats } from "@/hooks/useFilteredMemoStats"; import useMediaQuery from "@/hooks/useMediaQuery"; import { useNotifications, useUser } from "@/hooks/useUserQueries"; -import { getMemoScopePath, isMemoScopeRoute, type PrimaryMemoScope, resolveMemoScope } from "@/lib/memo-views"; +import { getMemoScopePath, getProfileUsername, type PrimaryMemoScope, resolveMemoScope } from "@/lib/memo-views"; +import { userNamePrefix } from "@/lib/resource-names"; import { cn } from "@/lib/utils"; import { ROUTES } from "@/router/routes"; import { State } from "@/types/proto/api/v1/common_pb"; @@ -126,9 +127,9 @@ const CollectionSidebarContent = ({ context }: { context: MemoStatsContext }) => const { mobileOpen, setMobileOpen } = useAppSidebar(); const { isInitialized: authInitialized } = useAuth(); const { isInitialized: instanceInitialized } = useInstance(); - const profileMatch = matchPath("/u/:username", location.pathname); - const { data: profileUser } = useUser(profileMatch?.params.username ? `users/${profileMatch.params.username}` : "", { - enabled: context === "profile" && !!profileMatch?.params.username, + const profileUsername = getProfileUsername(location.pathname); + const { data: profileUser } = useUser(`${userNamePrefix}${profileUsername ?? ""}`, { + enabled: context === "profile" && profileUsername !== undefined, }); const statsUserName = context === "home" ? currentUser?.name : context === "profile" ? profileUser?.name : undefined; // User-level collections stay aligned with their unscoped feeds even when a Space is remembered. @@ -141,12 +142,6 @@ const CollectionSidebarContent = ({ context }: { context: MemoStatsContext }) => enabled: authInitialized && instanceInitialized && (md || mobileOpen), }); - const showViews = !!currentUser && (context === "home" || context === "archived" || context === "explore"); - - // Off the collection routes (the library shown as fallback content), calendar and tag - // clicks must land somewhere that renders the filtered feed. - const onCollectionRoute = isMemoScopeRoute(location.pathname) || !!profileMatch; - const filterTarget = onCollectionRoute ? undefined : context === "explore" ? ROUTES.EXPLORE : ROUTES.HOME; const tagStateScope = isUserLevelCollection ? (statsUserName ?? context) : `${statsUserName ?? context}${selectedSpaceName ? `:${selectedSpaceName}` : ""}`; @@ -155,10 +150,11 @@ const CollectionSidebarContent = ({ context }: { context: MemoStatsContext }) =>
{context === "profile" && } - setMobileOpen(false)} /> + setMobileOpen(false)} /> - {showViews && } - setMobileOpen(false)} /> + {/* Every collection route narrows the same way: views (yours, so signed-in only), days, tags. */} + {currentUser && } + setMobileOpen(false)} />
); }; diff --git a/web/src/components/AppSidebar/QuickFindDialog.tsx b/web/src/components/AppSidebar/QuickFindDialog.tsx index fee93cb3..e046b35d 100644 --- a/web/src/components/AppSidebar/QuickFindDialog.tsx +++ b/web/src/components/AppSidebar/QuickFindDialog.tsx @@ -9,7 +9,7 @@ import { type MemoFilter, replaceFiltersByFactor, stringifyFilters, useMemoFilte import { useSpaceContext } from "@/contexts/SpaceContext"; import useCurrentUser from "@/hooks/useCurrentUser"; import { useMemoViews } from "@/hooks/useUserQueries"; -import { BUILTIN_TASKS_VIEW_ID, getMemoViewId, isMemoScopeRoute } from "@/lib/memo-views"; +import { BUILTIN_TASKS_VIEW_ID, getMemoViewId, isMemoCollectionRoute } from "@/lib/memo-views"; import { extractSpaceUidFromName, formatSpaceUidForDisplay } from "@/lib/space-display"; import { useTranslate } from "@/utils/i18n"; import { getRouteActionPolicy, getSidebarRouteKind } from "./routes"; @@ -59,7 +59,7 @@ const QuickFindDialog = () => { const { clearSelectedSpace, duplicateSpaceTitles, selectedSpace, selectedSpaceName } = useSpaceContext(); const { quickFindOpen, setQuickFindOpen } = useAppSidebar(); const [query, setQuery] = useState(""); - const viewApplies = isMemoScopeRoute(location.pathname); + const viewApplies = isMemoCollectionRoute(location.pathname); const selectedMemoView = viewApplies ? memoViews.find((item) => getMemoViewId(item.name) === memoView) : undefined; const lensLabel = viewApplies && memoView === BUILTIN_TASKS_VIEW_ID ? t("common.tasks") : selectedMemoView?.title || getScopeLabel(location.pathname, t); diff --git a/web/src/components/AppSidebar/TagsSection.tsx b/web/src/components/AppSidebar/TagsSection.tsx index 82326ad8..bf5bff4f 100644 --- a/web/src/components/AppSidebar/TagsSection.tsx +++ b/web/src/components/AppSidebar/TagsSection.tsx @@ -1,8 +1,7 @@ import { HashIcon, ListIcon, ListTreeIcon } from "lucide-react"; import { forwardRef, useMemo } from "react"; -import { useNavigate } from "react-router-dom"; import { Button } from "@/components/ui/button"; -import { replaceFiltersByFactor, stringifyFilters, useMemoFilterContext } from "@/contexts/MemoFilterContext"; +import { useMemoFilterContext } from "@/contexts/MemoFilterContext"; import { useLocalStorage, useOverflowTitle } from "@/hooks"; import { cn } from "@/lib/utils"; import { useTranslate } from "@/utils/i18n"; @@ -23,8 +22,6 @@ import SidebarSection, { interface Props { tagCount: Record; onSelect?: () => void; - /** When set, tag clicks land on this route with the tag filter instead of filtering the current one. */ - navigationTarget?: string; /** Whose tags these are; keeps tree expansion state from bleeding between users and views. */ scope: string; } @@ -76,10 +73,9 @@ const FlatTagRow = ({ tag, amount, active, ariaLabel, onClick }: FlatTagRowProps ); }; -const TagsSection = ({ tagCount, onSelect, navigationTarget, scope }: Props) => { +const TagsSection = ({ tagCount, onSelect, scope }: Props) => { const t = useTranslate(); - const navigate = useNavigate(); - const { filters, setFilters, getFiltersByFactor, addFilter, removeFilter } = useMemoFilterContext(); + const { getFiltersByFactor, addFilter, removeFilter } = useMemoFilterContext(); const [treeMode, setTreeMode] = useLocalStorage("tag-view-as-tree", false); const activeTags = new Set(getFiltersByFactor("tagSearch").map((filter) => filter.value)); const activeTag = activeTags.values().next().value as string | undefined; @@ -90,13 +86,6 @@ const TagsSection = ({ tagCount, onSelect, navigationTarget, scope }: Props) => } const handleTagClick = (tag: string) => { - if (navigationTarget) { - const nextFilters = replaceFiltersByFactor(filters, "tagSearch", [{ factor: "tagSearch", value: tag }]); - setFilters(nextFilters); - navigate({ pathname: navigationTarget, search: `?filter=${stringifyFilters(nextFilters)}` }); - onSelect?.(); - return; - } const active = activeTags.has(tag); if (active) { removeFilter((filter) => filter.factor === "tagSearch" && filter.value === tag); diff --git a/web/src/components/AppSidebar/ViewsSection.tsx b/web/src/components/AppSidebar/ViewsSection.tsx index 413a5d70..18be8568 100644 --- a/web/src/components/AppSidebar/ViewsSection.tsx +++ b/web/src/components/AppSidebar/ViewsSection.tsx @@ -13,7 +13,7 @@ import { useMemoFilterContext } from "@/contexts/MemoFilterContext"; import useCurrentUser from "@/hooks/useCurrentUser"; import { useMemoViews, userKeys } from "@/hooks/useUserQueries"; import { handleError } from "@/lib/error"; -import { BUILTIN_TASKS_VIEW_ID, getMemoViewId, isMemoScopeRoute } from "@/lib/memo-views"; +import { BUILTIN_TASKS_VIEW_ID, getMemoViewId, isMemoCollectionRoute } from "@/lib/memo-views"; import { cn } from "@/lib/utils"; import { ROUTES } from "@/router/routes"; import type { MemoView } from "@/types/proto/api/v1/memo_view_service_pb"; @@ -47,7 +47,7 @@ const ViewsSection = ({ manageActive = false }: { manageActive?: boolean }) => { const handleView = (viewId: string) => { setMemoView(selectedMemoView === viewId ? undefined : viewId); - if (!isMemoScopeRoute(location.pathname)) navigate(ROUTES.HOME); + if (!isMemoCollectionRoute(location.pathname)) navigate(ROUTES.HOME); setMobileOpen(false); }; diff --git a/web/src/components/AppSidebar/routes.ts b/web/src/components/AppSidebar/routes.ts index 5dfb90af..46a25f48 100644 --- a/web/src/components/AppSidebar/routes.ts +++ b/web/src/components/AppSidebar/routes.ts @@ -1,5 +1,5 @@ import { matchPath } from "react-router-dom"; -import { isMemoScopeRoute, type MemoScope, resolveMemoScope } from "@/lib/memo-views"; +import { getProfileUsername, isMemoScopeRoute, type MemoScope, resolveMemoScope } from "@/lib/memo-views"; import { ROUTES } from "@/router/routes"; export type SidebarRouteKind = MemoScope | "profile" | "views" | "attachments" | "inbox" | "settings" | "memo" | "common"; @@ -17,7 +17,7 @@ export interface RouteActionPolicy { export const getSidebarRouteKind = (path: string): SidebarRouteKind => { const normalizedPath = path.length > 1 ? path.replace(/\/+$/, "") : path; if (isMemoScopeRoute(normalizedPath)) return resolveMemoScope(normalizedPath); - if (matchPath("/u/:username", normalizedPath)) return "profile"; + if (getProfileUsername(normalizedPath) !== undefined) return "profile"; if (matchPath(ROUTES.VIEWS, normalizedPath)) return "views"; if (matchPath(ROUTES.ATTACHMENTS, normalizedPath)) return "attachments"; if (matchPath(ROUTES.INBOX, normalizedPath)) return "inbox"; diff --git a/web/src/components/ColumnGrid/ColumnGrid.tsx b/web/src/components/ColumnGrid/ColumnGrid.tsx index 2081a1f9..20b1a236 100644 --- a/web/src/components/ColumnGrid/ColumnGrid.tsx +++ b/web/src/components/ColumnGrid/ColumnGrid.tsx @@ -10,6 +10,8 @@ interface ColumnGridProps { estimateHeight?: (item: T, context: { columnWidth: number }) => number; /** Optional node packed as the very first tile (e.g. the note composer). */ leading?: ReactNode; + /** Optional node spanning the packed columns above them all (e.g. a page identity block). */ + header?: ReactNode; /** Key that must land at the top of column one (e.g. a just-created memo), not the shortest column. */ priorityKey?: string; /** Upper bound on the column count; 0 or undefined means as many as fit. */ @@ -19,6 +21,7 @@ interface ColumnGridProps { } const LEADING_KEY = "__grid_leading__"; +const HEADER_KEY = "__grid_header__"; const GRID_MIN_COLUMN_WIDTH = 260; export const GRID_GAP = 12; @@ -76,6 +79,7 @@ function ColumnGrid({ renderItem, estimateHeight, leading, + header, priorityKey, maxColumns, maxColumnWidth, @@ -105,7 +109,15 @@ function ColumnGrid({ let columnWidth = count > 1 ? Math.floor((width - GRID_GAP * (count - 1)) / count) : width; if (maxColumnWidth != null) columnWidth = Math.min(columnWidth, maxColumnWidth); // Center the packed columns in whatever width the clamp leaves over. - const offsetX = Math.floor((width - (columnWidth * count + GRID_GAP * (count - 1))) / 2); + const packedWidth = columnWidth * count + GRID_GAP * (count - 1); + const offsetX = Math.floor((width - packedWidth) / 2); + + // The header is not a column item: it spans the packed columns and pushes them all down. + const headerEl = itemRefs.current.get(HEADER_KEY); + if (headerEl) { + headerEl.style.width = `${packedWidth}px`; + headerEl.style.left = `${offsetX}px`; + } // Ordered by feed position: the leading tile (composer) first, then items. const ordered: { key: string; el: HTMLDivElement }[] = []; @@ -133,12 +145,17 @@ function ColumnGrid({ // Pass 2 (reads): height of every card, measured once after the width writes so the // browser reflows a single time. We read the inner element, not the absolutely-positioned // wrapper (whose block-formatting context would fold in margins). + const measure = (el: HTMLElement) => { + const child = el.firstElementChild; + return child instanceof HTMLElement ? child.offsetHeight : el.offsetHeight; + }; const heightByKey = new Map(); for (const { key, el } of ordered) { - const child = el.firstElementChild; - heightByKey.set(key, child instanceof HTMLElement ? child.offsetHeight : el.offsetHeight); + heightByKey.set(key, measure(el)); } const heightOf = (key: string) => heightByKey.get(key) ?? 0; + // Same pass as the cards, so the header's width write above reflows with theirs. + const columnStartY = headerEl ? measure(headerEl) + GRID_GAP : 0; const pinnedKeys = new Set([LEADING_KEY]); if (priorityKey) { @@ -154,7 +171,7 @@ function ColumnGrid({ }, }); - const columnY = new Array(count).fill(0); + const columnY = new Array(count).fill(columnStartY); const pos = new Map(); for (const { key } of ordered) { const col = columnOf.get(key) ?? 0; @@ -265,6 +282,13 @@ function ColumnGrid({ return (
+ {header != null && ( + // Spans the packed columns; positioned with left/top like the leading tile so it is + // never a containing block for fixed descendants either. +
+ {header} +
+ )} {leading != null && ( // Positioned with left/top (see relayout), and deliberately WITHOUT // transform/will-change so it never establishes a containing block that would trap diff --git a/web/src/components/MemoFilters.tsx b/web/src/components/MemoFilters.tsx index ca277c45..b22bc546 100644 --- a/web/src/components/MemoFilters.tsx +++ b/web/src/components/MemoFilters.tsx @@ -20,7 +20,7 @@ import { Button } from "@/components/ui/button"; import { type FilterFactor, getMemoFilterKey, type MemoFilter, useMemoFilterContext } from "@/contexts/MemoFilterContext"; import useCurrentUser from "@/hooks/useCurrentUser"; import { useMemoViews } from "@/hooks/useUserQueries"; -import { BUILTIN_TASKS_VIEW_ID, getMemoViewId, isMemoScopeRoute } from "@/lib/memo-views"; +import { BUILTIN_TASKS_VIEW_ID, getMemoViewId, isMemoCollectionRoute } from "@/lib/memo-views"; import { cn } from "@/lib/utils"; import { useTranslate } from "@/utils/i18n"; @@ -98,7 +98,7 @@ const MemoFilters = ({ className }: { className?: string }) => { const currentUser = useCurrentUser(); const { filters, memoView, removeFilter, setMemoView } = useMemoFilterContext(); // A remembered view only narrows the collection routes; elsewhere it is dormant and must not be echoed. - const viewApplies = memoView !== undefined && isMemoScopeRoute(location.pathname); + const viewApplies = memoView !== undefined && isMemoCollectionRoute(location.pathname); const { data: memoViews = [] } = useMemoViews(viewApplies ? currentUser?.name : undefined); const handleRemoveFilter = (filter: MemoFilter) => { diff --git a/web/src/components/MemoView/navigation.ts b/web/src/components/MemoView/navigation.ts index 94ccf3c4..c1618cbe 100644 --- a/web/src/components/MemoView/navigation.ts +++ b/web/src/components/MemoView/navigation.ts @@ -1,4 +1,4 @@ -import { isMemoScopeRoute } from "@/lib/memo-views"; +import { getProfileUsername, isMemoScopeRoute } from "@/lib/memo-views"; import { ROUTES } from "@/router/routes"; export type MemoOriginScope = "all" | "preserve"; @@ -113,7 +113,7 @@ export const withMemoFilter = (page: string, filter: string): string => { const pathname = questionMark === -1 ? pathAndSearch : pathAndSearch.slice(0, questionMark); const search = questionMark === -1 ? "" : pathAndSearch.slice(questionMark + 1); const searchParams = new URLSearchParams(search); - if (/^\/u\//i.test(pathname) && searchParams.get("view") === "map") { + if (getProfileUsername(pathname) !== undefined && searchParams.get("view") === "map") { searchParams.delete("view"); } searchParams.set("filter", filter); diff --git a/web/src/components/PagedMemoList/PagedMemoList.tsx b/web/src/components/PagedMemoList/PagedMemoList.tsx index 05541bb2..f1cec227 100644 --- a/web/src/components/PagedMemoList/PagedMemoList.tsx +++ b/web/src/components/PagedMemoList/PagedMemoList.tsx @@ -47,6 +47,10 @@ interface Props { enabled?: boolean; /** Route-owned content rendered before the list and inside column one in grid mode. */ renderLeading?: (options: { useGrid: boolean }) => ReactNode; + /** Route-owned content spanning the full list width above every column (e.g. a page identity block). */ + renderHeader?: (options: { useGrid: boolean }) => ReactNode; + /** Replaces the generic empty-state message when the route knows why the list is empty. */ + emptyMessage?: string; } function useAutoFetchWhenNotScrollable({ @@ -195,6 +199,7 @@ const PagedMemoList = (props: Props) => { }, [isDisplayPending, hasNextPage, isFetchingNextPage, fetchNextPage]); const leadingContent = props.renderLeading?.({ useGrid }); + const headerContent = props.renderHeader?.({ useGrid }); // A freshly created memo is hoisted to the front; pin it to the top of column one so it // appears right under the composer instead of dropping into a random (shortest) column. @@ -219,7 +224,7 @@ const PagedMemoList = (props: Props) => { const emptyPlaceholder = !isDisplayPending && !isFetchingNextPage && !hasNextPage && displayMemoList.length === 0 ? ( - + ) : null; const initialLoader = isDisplayPending && showLoader ? : null; @@ -261,6 +266,7 @@ const PagedMemoList = (props: Props) => { getKey={getMemoKey} renderItem={(memo) => props.renderer(memo, { compact: effectiveCompact })} estimateHeight={estimateMemoCardHeight} + header={headerContent} leading={gridLeading} priorityKey={priorityKey} maxColumns={maxColumns} @@ -270,6 +276,7 @@ const PagedMemoList = (props: Props) => { ) : ( <> + {headerContent} {leadingContent} {initialLoader} diff --git a/web/src/components/StatisticsView/StatisticsView.tsx b/web/src/components/StatisticsView/StatisticsView.tsx index 7d5dec73..29adb84d 100644 --- a/web/src/components/StatisticsView/StatisticsView.tsx +++ b/web/src/components/StatisticsView/StatisticsView.tsx @@ -9,15 +9,13 @@ import { MonthNavigator } from "./MonthNavigator"; interface Props { statisticsData: StatisticsData; onDateSelect?: () => void; - /** When set, day clicks land on this route with the date filter instead of filtering the current one. */ - navigationTarget?: string; } const StatisticsView = (props: Props) => { const { statisticsData } = props; const { activityStats, timeBasis } = statisticsData; const { filters } = useMemoFilterContext(); - const navigateToDateFilter = useDateFilterNavigation(props.navigationTarget); + const navigateToDateFilter = useDateFilterNavigation(); const [visibleMonthString, setVisibleMonthString] = useState(dayjs().format("YYYY-MM")); const selectedDate = filters.find((filter) => filter.factor === "displayTime")?.value; diff --git a/web/src/hooks/useDateFilterNavigation.ts b/web/src/hooks/useDateFilterNavigation.ts index e1b96974..0683058d 100644 --- a/web/src/hooks/useDateFilterNavigation.ts +++ b/web/src/hooks/useDateFilterNavigation.ts @@ -2,7 +2,7 @@ import { useCallback } from "react"; import { useLocation, useNavigate } from "react-router-dom"; import { replaceFiltersByFactor, stringifyFilters, useMemoFilterContext } from "@/contexts/MemoFilterContext"; -export const useDateFilterNavigation = (targetPath?: string) => { +export const useDateFilterNavigation = () => { const navigate = useNavigate(); const location = useLocation(); const { filters, setFilters } = useMemoFilterContext(); @@ -10,14 +10,12 @@ export const useDateFilterNavigation = (targetPath?: string) => { const navigateToDateFilter = useCallback( (date: string) => { const nextFilters = replaceFiltersByFactor(filters, "displayTime", [{ factor: "displayTime", value: date }]); - const filterQuery = stringifyFilters(nextFilters); - const basePath = targetPath ?? location.pathname; - const nextSearchParams = targetPath ? new URLSearchParams() : new URLSearchParams(location.search); - nextSearchParams.set("filter", filterQuery); + const nextSearchParams = new URLSearchParams(location.search); + nextSearchParams.set("filter", stringifyFilters(nextFilters)); setFilters(nextFilters); - navigate({ pathname: basePath, search: nextSearchParams.toString() }); + navigate({ pathname: location.pathname, search: nextSearchParams.toString() }); }, - [filters, location.pathname, location.search, navigate, setFilters, targetPath], + [filters, location.pathname, location.search, navigate, setFilters], ); return navigateToDateFilter; diff --git a/web/src/lib/memo-views.ts b/web/src/lib/memo-views.ts index 65309387..8b79eeb5 100644 --- a/web/src/lib/memo-views.ts +++ b/web/src/lib/memo-views.ts @@ -21,6 +21,23 @@ export const isMemoScopeRoute = (pathname: string): boolean => { return comparablePath === ROUTES.HOME || comparablePath === ROUTES.EXPLORE || comparablePath === ROUTES.ARCHIVED; }; +const PROFILE_ROUTE_PATTERN = /^\/u\/([^/]+)$/i; + +/** The decoded username when `pathname` is a user profile (`/u/:username`), else undefined. */ +export const getProfileUsername = (pathname: string): string | undefined => { + const match = cleanPathname(pathname).match(PROFILE_ROUTE_PATTERN); + return match ? decodeURIComponent(match[1]) : undefined; +}; + +/** + * Routes that render a memo collection the sidebar can narrow: the scope routes plus a + * user profile. Views, calendar days and tags apply in place on all of them. This is a + * different question from `isMemoCollectionOrigin` (MemoView/navigation.ts), which asks + * whether returning to a route should keep the remembered Space. + */ +export const isMemoCollectionRoute = (pathname: string): boolean => + isMemoScopeRoute(pathname) || getProfileUsername(pathname) !== undefined; + export const getMemoScopePath = (scope: PrimaryMemoScope): string => { if (scope === "explore") return ROUTES.EXPLORE; return ROUTES.HOME; @@ -40,9 +57,9 @@ export const resolveMemoScope = (pathname: string, options: ResolveMemoScopeOpti if (comparablePath === ROUTES.ARCHIVED) return "archived"; if (comparablePath === ROUTES.HOME) return "home"; - const profileMatch = cleanPath.match(/^\/u\/([^/]+)$/i); - if (profileMatch) { - return options.currentUsername && decodeURIComponent(profileMatch[1]) === options.currentUsername ? "home" : "explore"; + const profileUsername = getProfileUsername(cleanPath); + if (profileUsername !== undefined) { + return options.currentUsername && profileUsername === options.currentUsername ? "home" : "explore"; } if (comparablePath.startsWith("/memos/") && options.detailFrom) { diff --git a/web/src/locales/ar.json b/web/src/locales/ar.json index 15a0d382..5914ebf9 100644 --- a/web/src/locales/ar.json +++ b/web/src/locales/ar.json @@ -257,8 +257,7 @@ "restored-successfully": "تمت الاستعادة بنجاح", "succeed-copy-content": "تم نسخ المحتوى بنجاح.", "succeed-copy-link": "تم نسخ الرابط بنجاح.", - "update-succeed": "تم التحديث بنجاح", - "user-not-found": "المستخدم غير موجود" + "update-succeed": "تم التحديث بنجاح" }, "reference": { "add-references": "إضافة مراجع", diff --git a/web/src/locales/bg.json b/web/src/locales/bg.json index dc4860d1..3be0daa7 100644 --- a/web/src/locales/bg.json +++ b/web/src/locales/bg.json @@ -328,8 +328,7 @@ "restored-successfully": "Възстановен успешно", "succeed-copy-content": "Съдържанието е копирано успешно.", "succeed-copy-link": "Връзката е копирана успешно.", - "update-succeed": "Актуализацията е успешна", - "user-not-found": "Потребителят не е намерен" + "update-succeed": "Актуализацията е успешна" }, "reference": { "add-references": "Добавете препратки", diff --git a/web/src/locales/ca.json b/web/src/locales/ca.json index 15f3a817..6b79967e 100644 --- a/web/src/locales/ca.json +++ b/web/src/locales/ca.json @@ -291,8 +291,7 @@ "restored-successfully": "Restaurat correctament", "succeed-copy-content": "Contingut copiat correctament.", "succeed-copy-link": "Enllaç copiat correctament.", - "update-succeed": "Actualització correcta", - "user-not-found": "Usuari no trobat" + "update-succeed": "Actualització correcta" }, "reference": { "add-references": "Afegeix referències", diff --git a/web/src/locales/cs.json b/web/src/locales/cs.json index b80be67a..304535bb 100644 --- a/web/src/locales/cs.json +++ b/web/src/locales/cs.json @@ -291,8 +291,7 @@ "restored-successfully": "Úspěšně obnoveno", "succeed-copy-content": "Obsah úspěšně zkopírován.", "succeed-copy-link": "Odkaz byl úspěšně zkopírován.", - "update-succeed": "Aktualizace proběhla úspěšně", - "user-not-found": "Uživatel nenalezen" + "update-succeed": "Aktualizace proběhla úspěšně" }, "reference": { "add-references": "Přidat odkazy", diff --git a/web/src/locales/da.json b/web/src/locales/da.json index b01ba08c..62e0cead 100644 --- a/web/src/locales/da.json +++ b/web/src/locales/da.json @@ -328,8 +328,7 @@ "restored-successfully": "Gendannet med succes", "succeed-copy-content": "Indholdet blev kopieret.", "succeed-copy-link": "Linket blev kopieret.", - "update-succeed": "Opdatering lykkedes", - "user-not-found": "Bruger ikke fundet" + "update-succeed": "Opdatering lykkedes" }, "reference": { "add-references": "Tilføj referencer", diff --git a/web/src/locales/de.json b/web/src/locales/de.json index e5e2b548..26fa2da8 100644 --- a/web/src/locales/de.json +++ b/web/src/locales/de.json @@ -291,8 +291,7 @@ "restored-successfully": "Erfolgreich wiederhergestellt", "succeed-copy-content": "Inhalt erfolgreich kopiert.", "succeed-copy-link": "Link erfolgreich kopiert", - "update-succeed": "Update erfolgreich", - "user-not-found": "Benutzer nicht gefunden" + "update-succeed": "Update erfolgreich" }, "reference": { "add-references": "Referenzen hinzufügen", diff --git a/web/src/locales/el.json b/web/src/locales/el.json index e16ce3cf..c853cd97 100644 --- a/web/src/locales/el.json +++ b/web/src/locales/el.json @@ -328,8 +328,7 @@ "restored-successfully": "Έγινε επαναφορά με επιτυχία", "succeed-copy-content": "Το περιεχόμενο αντιγράφηκε με επιτυχία.", "succeed-copy-link": "Ο σύνδεσμος αντιγράφηκε με επιτυχία.", - "update-succeed": "Η ενημέρωση ολοκληρώθηκε με επιτυχία", - "user-not-found": "Ο χρήστης δεν βρέθηκε" + "update-succeed": "Η ενημέρωση ολοκληρώθηκε με επιτυχία" }, "reference": { "add-references": "Προσθήκη παραπομπών", diff --git a/web/src/locales/en-GB.json b/web/src/locales/en-GB.json index 658b04be..6d878d40 100644 --- a/web/src/locales/en-GB.json +++ b/web/src/locales/en-GB.json @@ -291,8 +291,7 @@ "restored-successfully": "Restored successfully", "succeed-copy-content": "Content copied successfully.", "succeed-copy-link": "Link copied successfully.", - "update-succeed": "Update succeeded", - "user-not-found": "User not found" + "update-succeed": "Update succeeded" }, "reference": { "add-references": "Add references", diff --git a/web/src/locales/en.json b/web/src/locales/en.json index c47d1d5b..5b6b17f4 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -465,8 +465,12 @@ "restored-successfully": "Restored successfully", "succeed-copy-content": "Content copied successfully.", "succeed-copy-link": "Link copied successfully.", - "update-succeed": "Update succeeded", - "user-not-found": "User not found" + "update-succeed": "Update succeeded" + }, + "profile": { + "no-shared-memos": "@{{username}} hasn't shared any memos yet.", + "not-found-description": "There's no Memos user named @{{username}} on this instance.", + "not-found-title": "No one here" }, "reference": { "add-references": "Add references", diff --git a/web/src/locales/es.json b/web/src/locales/es.json index 507373a7..1fb81f2e 100644 --- a/web/src/locales/es.json +++ b/web/src/locales/es.json @@ -291,8 +291,7 @@ "restored-successfully": "Restaurado con éxito", "succeed-copy-content": "Contenido copiado correctamente.", "succeed-copy-link": "Enlace copiado correctamente.", - "update-succeed": "Actualización exitosa", - "user-not-found": "Usuario no encontrado" + "update-succeed": "Actualización exitosa" }, "reference": { "add-references": "Agregar referencias", diff --git a/web/src/locales/et.json b/web/src/locales/et.json index 83130de1..2574272d 100644 --- a/web/src/locales/et.json +++ b/web/src/locales/et.json @@ -328,8 +328,7 @@ "restored-successfully": "Taastatud edukalt", "succeed-copy-content": "Sisu kopeerimine õnnestus.", "succeed-copy-link": "Link on edukalt kopeeritud.", - "update-succeed": "Värskendus õnnestus", - "user-not-found": "Kasutajat ei leitud" + "update-succeed": "Värskendus õnnestus" }, "reference": { "add-references": "Lisa viited", diff --git a/web/src/locales/fa.json b/web/src/locales/fa.json index 94ba95de..37d92b76 100644 --- a/web/src/locales/fa.json +++ b/web/src/locales/fa.json @@ -257,8 +257,7 @@ "restored-successfully": "با موفقیت بازیابی شد", "succeed-copy-content": "محتوا با موفقیت کپی شد.", "succeed-copy-link": "پیوند با موفقیت کپی شد.", - "update-succeed": "بروزرسانی موفق بود", - "user-not-found": "کاربر یافت نشد" + "update-succeed": "بروزرسانی موفق بود" }, "reference": { "add-references": "افزودن منابع", diff --git a/web/src/locales/fi.json b/web/src/locales/fi.json index 1f54a068..dcf7f908 100644 --- a/web/src/locales/fi.json +++ b/web/src/locales/fi.json @@ -328,8 +328,7 @@ "restored-successfully": "Palautettu onnistuneesti", "succeed-copy-content": "Sisällön kopiointi onnistui.", "succeed-copy-link": "Linkin kopioiminen onnistui.", - "update-succeed": "Päivitys onnistui", - "user-not-found": "Käyttäjää ei löydy" + "update-succeed": "Päivitys onnistui" }, "reference": { "add-references": "Lisää viitteitä", diff --git a/web/src/locales/fr.json b/web/src/locales/fr.json index 1967a8b4..7bb36580 100644 --- a/web/src/locales/fr.json +++ b/web/src/locales/fr.json @@ -291,8 +291,7 @@ "restored-successfully": "Restauré avec succès", "succeed-copy-content": "Contenu copié avec succès.", "succeed-copy-link": "Lien copié avec succès.", - "update-succeed": "Mise à jour réussie", - "user-not-found": "Utilisateur non trouvé" + "update-succeed": "Mise à jour réussie" }, "reference": { "add-references": "Ajouter des références", diff --git a/web/src/locales/gl.json b/web/src/locales/gl.json index 47d478ca..13a38689 100644 --- a/web/src/locales/gl.json +++ b/web/src/locales/gl.json @@ -291,8 +291,7 @@ "restored-successfully": "Recuperación correcta", "succeed-copy-content": "Contido copiado correctamente.", "succeed-copy-link": "Ligazón copiada correctamente.", - "update-succeed": "Fíxose a actualización", - "user-not-found": "Non se atopa a usuaria" + "update-succeed": "Fíxose a actualización" }, "reference": { "add-references": "Engadir referencias", diff --git a/web/src/locales/he.json b/web/src/locales/he.json index 2ba2cda6..4913c7f7 100644 --- a/web/src/locales/he.json +++ b/web/src/locales/he.json @@ -454,8 +454,7 @@ "restored-successfully": "שוחזר בהצלחה", "succeed-copy-content": "התוכן הועתק בהצלחה.", "succeed-copy-link": "הקישור הועתק בהצלחה.", - "update-succeed": "העדכון הצליח", - "user-not-found": "המשתמש לא נמצא" + "update-succeed": "העדכון הצליח" }, "reference": { "add-references": "הוסף הפניות", diff --git a/web/src/locales/hi.json b/web/src/locales/hi.json index 61ae0cd0..7ebde120 100644 --- a/web/src/locales/hi.json +++ b/web/src/locales/hi.json @@ -257,8 +257,7 @@ "restored-successfully": "सफलतापूर्वक पुनर्स्थापित किया गया", "succeed-copy-content": "सामग्री सफलतापूर्वक कॉपी की गई।", "succeed-copy-link": "लिंक सफलतापूर्वक कॉपी किया गया।", - "update-succeed": "अपडेट सफल हुआ", - "user-not-found": "उपयोगकर्ता नहीं मिला" + "update-succeed": "अपडेट सफल हुआ" }, "reference": { "add-references": "संदर्भ जोड़ें", diff --git a/web/src/locales/hr.json b/web/src/locales/hr.json index aafafafa..16f8a8c5 100644 --- a/web/src/locales/hr.json +++ b/web/src/locales/hr.json @@ -291,8 +291,7 @@ "restored-successfully": "Uspješno vraćeno", "succeed-copy-content": "Sadržaj uspješno kopiran.", "succeed-copy-link": "Link je uspješno kopiran.", - "update-succeed": "Ažuriranje uspješno", - "user-not-found": "Korisnik nije pronađen" + "update-succeed": "Ažuriranje uspješno" }, "reference": { "add-references": "Dodaj reference", diff --git a/web/src/locales/hu.json b/web/src/locales/hu.json index 93f76146..fa0a7be5 100644 --- a/web/src/locales/hu.json +++ b/web/src/locales/hu.json @@ -291,8 +291,7 @@ "restored-successfully": "Sikeres visszaállítás", "succeed-copy-content": "Tartalom sikeresen másolva.", "succeed-copy-link": "Hivatkozás sikeresen másolva.", - "update-succeed": "Sikeres frissítés", - "user-not-found": "Felhasználó nem található" + "update-succeed": "Sikeres frissítés" }, "reference": { "add-references": "Referenciák hozzáadása", diff --git a/web/src/locales/id.json b/web/src/locales/id.json index 574dbcf7..ed427df7 100644 --- a/web/src/locales/id.json +++ b/web/src/locales/id.json @@ -257,8 +257,7 @@ "restored-successfully": "Berhasil dipulihkan", "succeed-copy-content": "Konten berhasil disalin.", "succeed-copy-link": "Tautan berhasil disalin.", - "update-succeed": "Pembaruan berhasil", - "user-not-found": "Pengguna tidak ditemukan" + "update-succeed": "Pembaruan berhasil" }, "reference": { "add-references": "Tambah referensi", diff --git a/web/src/locales/it.json b/web/src/locales/it.json index fec51af4..2d08cf8f 100644 --- a/web/src/locales/it.json +++ b/web/src/locales/it.json @@ -291,8 +291,7 @@ "restored-successfully": "Ripristinato con successo", "succeed-copy-content": "Contenuto copiato con successo.", "succeed-copy-link": "Link copiato.", - "update-succeed": "Aggiornato con successo", - "user-not-found": "Utente non trovato" + "update-succeed": "Aggiornato con successo" }, "reference": { "add-references": "Aggiungi riferimenti", diff --git a/web/src/locales/ja.json b/web/src/locales/ja.json index 60dfacb0..7af68316 100644 --- a/web/src/locales/ja.json +++ b/web/src/locales/ja.json @@ -365,8 +365,7 @@ "restored-successfully": "復元しました", "succeed-copy-content": "コンテンツのコピーに成功しました。", "succeed-copy-link": "リンクのコピーに成功しました。", - "update-succeed": "変更は保存されました", - "user-not-found": "ユーザーが見つかりませんでした" + "update-succeed": "変更は保存されました" }, "reference": { "add-references": "参照を追加", diff --git a/web/src/locales/ka-GE.json b/web/src/locales/ka-GE.json index 530c8b88..5bfb0b00 100644 --- a/web/src/locales/ka-GE.json +++ b/web/src/locales/ka-GE.json @@ -291,8 +291,7 @@ "restored-successfully": "წარმატებით აღდგა", "succeed-copy-content": "კონტენტი წარმატებით კოპირდა.", "succeed-copy-link": "ლინკი წარმატებით კოპირდა.", - "update-succeed": "განახლება წარმატებით დასრულდა", - "user-not-found": "მომხმარებელი ვერ მოიძებნა" + "update-succeed": "განახლება წარმატებით დასრულდა" }, "reference": { "add-references": "რეფერენციის დამატება", diff --git a/web/src/locales/ko.json b/web/src/locales/ko.json index d569e666..668c8303 100644 --- a/web/src/locales/ko.json +++ b/web/src/locales/ko.json @@ -257,8 +257,7 @@ "restored-successfully": "성공적으로 복구했습니다", "succeed-copy-content": "콘텐츠를 클립보드에 복사했습니다.", "succeed-copy-link": "링크를 클립보드에 복사했습니다.", - "update-succeed": "업데이트 성공", - "user-not-found": "회원을 찾을 수 없습니다" + "update-succeed": "업데이트 성공" }, "reference": { "add-references": "참조 추가", diff --git a/web/src/locales/lt.json b/web/src/locales/lt.json index 86bf5ce6..384241cc 100644 --- a/web/src/locales/lt.json +++ b/web/src/locales/lt.json @@ -328,8 +328,7 @@ "restored-successfully": "Sėkmingai atkurta", "succeed-copy-content": "Turinys sėkmingai nukopijuotas.", "succeed-copy-link": "Nuoroda sėkmingai nukopijuota.", - "update-succeed": "Atnaujinimas pavyko", - "user-not-found": "Vartotojas nerastas" + "update-succeed": "Atnaujinimas pavyko" }, "reference": { "add-references": "Pridėti nuorodas", diff --git a/web/src/locales/lv.json b/web/src/locales/lv.json index a68fa2cd..2c140cf8 100644 --- a/web/src/locales/lv.json +++ b/web/src/locales/lv.json @@ -328,8 +328,7 @@ "restored-successfully": "Veiksmīgi atjaunots", "succeed-copy-content": "Saturs ir veiksmīgi kopēts.", "succeed-copy-link": "Saite ir veiksmīgi nokopēta.", - "update-succeed": "Atjaunināšana izdevās", - "user-not-found": "Lietotājs nav atrasts" + "update-succeed": "Atjaunināšana izdevās" }, "reference": { "add-references": "Pievienojiet atsauces", diff --git a/web/src/locales/mr.json b/web/src/locales/mr.json index 5a645e7f..4fa83fef 100644 --- a/web/src/locales/mr.json +++ b/web/src/locales/mr.json @@ -257,8 +257,7 @@ "restored-successfully": "यशस्वीरित्या पुनर्संचयित केले", "succeed-copy-content": "सामग्री यशस्वीरित्या कॉपी केली.", "succeed-copy-link": "लिंक यशस्वीरित्या कॉपी केली.", - "update-succeed": "अपडेट यशस्वी झाले", - "user-not-found": "वापरकर्ता सापडला नाही" + "update-succeed": "अपडेट यशस्वी झाले" }, "reference": { "add-references": "संदर्भ जोडा", diff --git a/web/src/locales/nb.json b/web/src/locales/nb.json index 4b588c2a..f04bcdfc 100644 --- a/web/src/locales/nb.json +++ b/web/src/locales/nb.json @@ -291,8 +291,7 @@ "restored-successfully": "Gjenoppretting vellykket", "succeed-copy-content": "Innhold kopiert vellykket.", "succeed-copy-link": "Link kopiert.", - "update-succeed": "Oppdatering vellykket", - "user-not-found": "Bruker ikke funnet" + "update-succeed": "Oppdatering vellykket" }, "reference": { "add-references": "Legg til referanser", diff --git a/web/src/locales/nl.json b/web/src/locales/nl.json index 1c8cb203..a0917ce6 100644 --- a/web/src/locales/nl.json +++ b/web/src/locales/nl.json @@ -291,8 +291,7 @@ "restored-successfully": "Succesvol teruggezet", "succeed-copy-content": "Inhoud succesvol gekopieerd.", "succeed-copy-link": "Link gekopieerd naar klembord.", - "update-succeed": "Update voltooid", - "user-not-found": "Gebruiker niet gevonden" + "update-succeed": "Update voltooid" }, "reference": { "add-references": "Referenties toevoegen", diff --git a/web/src/locales/pl.json b/web/src/locales/pl.json index 3df281e5..3d95193d 100644 --- a/web/src/locales/pl.json +++ b/web/src/locales/pl.json @@ -310,8 +310,7 @@ "restored-successfully": "Przywrócono pomyślnie", "succeed-copy-content": "Treść została pomyślnie skopiowana.", "succeed-copy-link": "Link skopiowany pomyślnie.", - "update-succeed": "Aktualizacja zakończona sukcesem", - "user-not-found": "Użytkownik nie został znaleziony" + "update-succeed": "Aktualizacja zakończona sukcesem" }, "reference": { "add-references": "Dodaj odniesienia", diff --git a/web/src/locales/pt-BR.json b/web/src/locales/pt-BR.json index b79d9c44..c24cd900 100644 --- a/web/src/locales/pt-BR.json +++ b/web/src/locales/pt-BR.json @@ -257,8 +257,7 @@ "restored-successfully": "Restaurado com êxito", "succeed-copy-content": "Conteúdo copiado com êxito.", "succeed-copy-link": "Link copiado com êxito.", - "update-succeed": "Atualizado com êxito", - "user-not-found": "Usuário não encontrado" + "update-succeed": "Atualizado com êxito" }, "reference": { "add-references": "Adicionar referências", diff --git a/web/src/locales/pt-PT.json b/web/src/locales/pt-PT.json index bf3ab202..ee933782 100644 --- a/web/src/locales/pt-PT.json +++ b/web/src/locales/pt-PT.json @@ -291,8 +291,7 @@ "restored-successfully": "Restaurado com sucesso", "succeed-copy-content": "Conteúdo copiado com sucesso.", "succeed-copy-link": "Link copiado com sucesso.", - "update-succeed": "Atualização bem-sucedida", - "user-not-found": "Utilizador não encontrado" + "update-succeed": "Atualização bem-sucedida" }, "reference": { "add-references": "Adicionar referências", diff --git a/web/src/locales/ro.json b/web/src/locales/ro.json index c11d0b60..ae0aab88 100644 --- a/web/src/locales/ro.json +++ b/web/src/locales/ro.json @@ -328,8 +328,7 @@ "restored-successfully": "Restaurat cu succes", "succeed-copy-content": "Conținutul a fost copiat cu succes.", "succeed-copy-link": "Linkul a fost copiat cu succes.", - "update-succeed": "Actualizarea a reușit", - "user-not-found": "Utilizatorul nu a fost găsit" + "update-succeed": "Actualizarea a reușit" }, "reference": { "add-references": "Adăugați referințe", diff --git a/web/src/locales/ru.json b/web/src/locales/ru.json index f313b3fb..e50b82c6 100644 --- a/web/src/locales/ru.json +++ b/web/src/locales/ru.json @@ -385,8 +385,7 @@ "restored-successfully": "Успешно восстановлено.", "succeed-copy-content": "Контент успешно скопирован.", "succeed-copy-link": "Ссылка скопирована в буфер обмена.", - "update-succeed": "Успешно обновлено", - "user-not-found": "Пользователь не найден" + "update-succeed": "Успешно обновлено" }, "reference": { "add-references": "Добавить связь", diff --git a/web/src/locales/sk.json b/web/src/locales/sk.json index 20e34472..3b921eb6 100644 --- a/web/src/locales/sk.json +++ b/web/src/locales/sk.json @@ -328,8 +328,7 @@ "restored-successfully": "Úspešne obnovené", "succeed-copy-content": "Obsah bol úspešne skopírovaný.", "succeed-copy-link": "Odkaz bol úspešne skopírovaný.", - "update-succeed": "Aktualizácia bola úspešná", - "user-not-found": "Používateľ sa nenašiel" + "update-succeed": "Aktualizácia bola úspešná" }, "reference": { "add-references": "Pridajte referencie", diff --git a/web/src/locales/sl.json b/web/src/locales/sl.json index 6812635e..e1c3678f 100644 --- a/web/src/locales/sl.json +++ b/web/src/locales/sl.json @@ -291,8 +291,7 @@ "restored-successfully": "Uspešno obnovljeno", "succeed-copy-content": "Vsebina je uspešno skopirana.", "succeed-copy-link": "Povezava je uspešno skopirana.", - "update-succeed": "Posodobitev je uspešna", - "user-not-found": "Ne najdem uporabnika" + "update-succeed": "Posodobitev je uspešna" }, "reference": { "add-references": "Dodaj referenco", diff --git a/web/src/locales/sr.json b/web/src/locales/sr.json index 63aed42c..57e27992 100644 --- a/web/src/locales/sr.json +++ b/web/src/locales/sr.json @@ -328,8 +328,7 @@ "restored-successfully": "Успешно враћено", "succeed-copy-content": "Садржај је успешно копиран.", "succeed-copy-link": "Линк је успешно копиран.", - "update-succeed": "Ажурирање је успело", - "user-not-found": "Корисник није пронађен" + "update-succeed": "Ажурирање је успело" }, "reference": { "add-references": "Додајте референце", diff --git a/web/src/locales/sv.json b/web/src/locales/sv.json index 39ba9ff1..e40f24ef 100644 --- a/web/src/locales/sv.json +++ b/web/src/locales/sv.json @@ -291,8 +291,7 @@ "restored-successfully": "Återställdes framgångsrikt", "succeed-copy-content": "Innehåll kopierades framgångsrikt.", "succeed-copy-link": "Länk kopierades framgångsrikt.", - "update-succeed": "Uppdatering lyckades", - "user-not-found": "Användaren hittades inte" + "update-succeed": "Uppdatering lyckades" }, "reference": { "add-references": "Lägg till referenser", diff --git a/web/src/locales/th.json b/web/src/locales/th.json index 0fed3b7b..d40e2a82 100644 --- a/web/src/locales/th.json +++ b/web/src/locales/th.json @@ -257,8 +257,7 @@ "restored-successfully": "กู้คืนเรียบร้อยแล้ว", "succeed-copy-content": "คัดลอกเนื้อหาเรียบร้อยแล้ว", "succeed-copy-link": "คัดลอกลิงก์เรียบร้อยแล้ว", - "update-succeed": "อัปเดตเรียบร้อยแล้ว", - "user-not-found": "ไม่พบผู้ใช้งาน" + "update-succeed": "อัปเดตเรียบร้อยแล้ว" }, "reference": { "add-references": "เพิ่มข้อมูลอ้างอิง", diff --git a/web/src/locales/tr.json b/web/src/locales/tr.json index 729df6d1..b12dab9e 100644 --- a/web/src/locales/tr.json +++ b/web/src/locales/tr.json @@ -291,8 +291,7 @@ "restored-successfully": "Başarıyla geri yüklendi", "succeed-copy-content": "İçerik başarıyla kopyalandı.", "succeed-copy-link": "Bağlantı başarıyla kopyalandı.", - "update-succeed": "Güncelleme başarılı", - "user-not-found": "Kullanıcı bulunamadı" + "update-succeed": "Güncelleme başarılı" }, "reference": { "add-references": "Referans ekle", diff --git a/web/src/locales/uk.json b/web/src/locales/uk.json index 2c7e47eb..e46766a5 100644 --- a/web/src/locales/uk.json +++ b/web/src/locales/uk.json @@ -291,8 +291,7 @@ "restored-successfully": "Успішно відновлено", "succeed-copy-content": "Вміст успішно скопійовано.", "succeed-copy-link": "Посилання успішно скопійовано.", - "update-succeed": "Оновлення успішне", - "user-not-found": "Користувача не знайдено" + "update-succeed": "Оновлення успішне" }, "reference": { "add-references": "Додати посилання", diff --git a/web/src/locales/vi.json b/web/src/locales/vi.json index de6eb697..bfdda122 100644 --- a/web/src/locales/vi.json +++ b/web/src/locales/vi.json @@ -257,8 +257,7 @@ "restored-successfully": "Khôi phục thành công", "succeed-copy-content": "Đã sao chép nội dung thành công.", "succeed-copy-link": "Sao chép liên kết thành công.", - "update-succeed": "Cập nhật thành công", - "user-not-found": "Không tìm thấy người dùng" + "update-succeed": "Cập nhật thành công" }, "reference": { "add-references": "Thêm tham chiếu", diff --git a/web/src/locales/zh-Hans.json b/web/src/locales/zh-Hans.json index 20862819..c61b9ef7 100644 --- a/web/src/locales/zh-Hans.json +++ b/web/src/locales/zh-Hans.json @@ -386,8 +386,7 @@ "restored-successfully": "恢复成功", "succeed-copy-content": "复制内容到剪贴板成功。", "succeed-copy-link": "复制链接到剪贴板成功。", - "update-succeed": "更新成功", - "user-not-found": "未找到该用户" + "update-succeed": "更新成功" }, "reference": { "add-references": "添加引用", diff --git a/web/src/locales/zh-Hant.json b/web/src/locales/zh-Hant.json index e55e1c42..2d8b430a 100644 --- a/web/src/locales/zh-Hant.json +++ b/web/src/locales/zh-Hant.json @@ -459,8 +459,7 @@ "restored-successfully": "還原成功", "succeed-copy-content": "內容複製到剪貼簿成功。", "succeed-copy-link": "複製連結到剪貼簿成功。", - "update-succeed": "更新成功", - "user-not-found": "未找到該使用者" + "update-succeed": "更新成功" }, "reference": { "add-references": "引用參考資料", diff --git a/web/src/pages/UserProfile.tsx b/web/src/pages/UserProfile.tsx index ab46e2d6..a7c3a875 100644 --- a/web/src/pages/UserProfile.tsx +++ b/web/src/pages/UserProfile.tsx @@ -1,16 +1,20 @@ -import copy from "copy-to-clipboard"; -import { ExternalLinkIcon } from "lucide-react"; -import { Suspense } from "react"; -import { toast } from "react-hot-toast"; -import { useParams, useSearchParams } from "react-router-dom"; +import { UserRoundIcon } from "lucide-react"; +import { type ReactNode, Suspense } from "react"; +import { Link, useParams, useSearchParams } from "react-router-dom"; import MemoView from "@/components/MemoView"; import PagedMemoList, { getMemoKey } from "@/components/PagedMemoList"; import UserAvatar from "@/components/UserAvatar"; -import { Button } from "@/components/ui/button"; import { useMemoFilters, useMemoSorting } from "@/hooks"; +import useCurrentUser from "@/hooks/useCurrentUser"; +import { useDelayedFlag } from "@/hooks/useDelayedFlag"; import { useUser } from "@/hooks/useUserQueries"; +import { LOADING_INDICATOR_DELAY_MS } from "@/lib/constants"; +import { userNamePrefix } from "@/lib/resource-names"; +import { cn } from "@/lib/utils"; +import { ROUTES } from "@/router/routes"; import { State } from "@/types/proto/api/v1/common_pb"; import { Memo } from "@/types/proto/api/v1/memo_service_pb"; +import type { User } from "@/types/proto/api/v1/user_service_pb"; import { useTranslate } from "@/utils/i18n"; import { lazyWithReload } from "@/utils/lazy"; @@ -18,48 +22,73 @@ type TabView = "memos" | "map"; const UserMemoMap = lazyWithReload(() => import("@/components/UserMemoMap")); -interface User { - name: string; - username: string; - displayName: string; - avatarUrl?: string; - description?: string; -} +const PROFILE_TITLE_CLASSES = "text-xl font-semibold leading-7 tracking-[-0.01em] text-foreground"; +const PROFILE_AVATAR_SLOT_CLASSES = "mt-0.5 size-10 shrink-0 rounded-lg"; -const ProfileHeader = ({ user, onCopyProfileLink, shareLabel }: { user: User; onCopyProfileLink: () => void; shareLabel: string }) => ( -
-
- -
-
-

{user.displayName || user.username}

- {user.displayName &&

@{user.username}

} -
- {user.description &&

{user.description}

} - -
-
+// The identity block sits on the content rail like everything else on the page: a 40px +// avatar slot beside a text column. The loaded, loading and not-found states all share +// this shell so they occupy the same space and swap without a jump. +const IdentityRow = ({ avatar, className, children }: { avatar: ReactNode; className?: string; children: ReactNode }) => ( +
+ {avatar} +
{children}
); +// The list's header, so in grid mode it spans every column. +const ProfileHeader = ({ user, className }: { user: User; className?: string }) => ( + }> +
+

{user.displayName || user.username}

+ {user.displayName && @{user.username}} +
+ {user.description &&

{user.description}

} +
+); + +const ProfileHeaderSkeleton = () => ( +
+ }> + + + +
+); + +const ProfileNotFound = ({ username }: { username: string }) => { + const t = useTranslate(); + return ( + + + + } + > +

{t("profile.not-found-title")}

+

{t("profile.not-found-description", { username })}

+ + {t("common.explore")} + +
+ ); +}; + const UserProfile = () => { const t = useTranslate(); - const username = useParams().username; + const username = useParams().username ?? ""; const [searchParams] = useSearchParams(); + const currentUser = useCurrentUser(); const activeTab = (searchParams.get("view") === "map" ? "map" : "memos") as TabView; - const { data: user, isLoading, error } = useUser(`users/${username}`, { enabled: !!username }); - - if (error && !isLoading) { - toast.error(t("message.user-not-found")); - } + const { data: user, isLoading } = useUser(`${userNamePrefix}${username}`, { enabled: !!username }); + const showSkeleton = useDelayedFlag(isLoading, LOADING_INDICATOR_DELAY_MS); const memoFilter = useMemoFilters({ creatorName: user?.name, - includeMemoViews: false, + includeMemoViews: true, includePinned: true, }); @@ -68,45 +97,38 @@ const UserProfile = () => { state: State.NORMAL, }); - const handleCopyProfileLink = () => { - if (!user) return; - copy(`${window.location.origin}/u/${encodeURIComponent(user.username)}`); - toast.success(t("message.copied")); - }; - - if (isLoading) return null; + if (user && activeTab === "memos") { + // Visitors only see what the backend lets them see, so an empty list means nothing + // shared rather than nothing written. The owner sees everything and gets the default. + const isOwner = currentUser?.name === user.name; + return ( + ( + + )} + listSort={listSort} + orderBy={orderBy} + filter={memoFilter} + emptyMessage={isOwner ? undefined : t("profile.no-shared-memos", { username: user.username })} + renderHeader={({ useGrid }) => } + /> + ); + } + // Everything that is not the list shares the list's single-column reading rail. return ( -
- {user ? ( - <> - - -
-
- {activeTab === "memos" ? ( - ( - - )} - listSort={listSort} - orderBy={orderBy} - filter={memoFilter} - /> - ) : ( -
- }> - - -
- )} -
-
- +
+ {isLoading ? ( + showSkeleton && + ) : !user ? ( + ) : ( -
-

{t("message.user-not-found")}

-
+ <> + + }> + + + )}
); diff --git a/web/src/router/index.tsx b/web/src/router/index.tsx index aab24b40..4fc277ce 100644 --- a/web/src/router/index.tsx +++ b/web/src/router/index.tsx @@ -84,7 +84,7 @@ export const routeConfig: RouteObject[] = [ children: [{ path: Routes.ABOUT, element: }], }, { path: Routes.EXPLORE, element: }, - { path: "u/:username", element: }, + { path: Routes.USER_PROFILE, element: }, { element: , children: [ diff --git a/web/src/router/routes.ts b/web/src/router/routes.ts index 9fda3a7d..90a54956 100644 --- a/web/src/router/routes.ts +++ b/web/src/router/routes.ts @@ -7,6 +7,7 @@ export const ROUTES = { VIEWS: "/views", SETTING: "/setting", EXPLORE: "/explore", + USER_PROFILE: "/u/:username", AUTH: "/auth", AUTH_SIGNUP: "/auth/signup", AUTH_ADMIN: "/auth/admin", diff --git a/web/tests/column-grid.test.tsx b/web/tests/column-grid.test.tsx index d0bd0e49..16ef9c0a 100644 --- a/web/tests/column-grid.test.tsx +++ b/web/tests/column-grid.test.tsx @@ -37,6 +37,31 @@ describe("", () => { expect(grid.children[0].querySelector('[data-testid="composer"]')).not.toBeNull(); }); + it("spans the header across the packed columns and starts every column below it", () => { + // 532px fits two 260px columns with a 12px gap; every measured height is 100px. + const clientWidth = vi.spyOn(HTMLElement.prototype, "clientWidth", "get").mockReturnValue(532); + const offsetHeight = vi.spyOn(HTMLElement.prototype, "offsetHeight", "get").mockReturnValue(100); + + const { getByTestId } = render( +
{i.id}
} + header={
} + />, + ); + + const header = getByTestId("identity").parentElement as HTMLElement; + expect(header.style.width).toBe("532px"); + expect(header.style.left).toBe("0px"); + // Header height plus one grid gap: both columns begin on the same line beneath it. + expect(getByTestId("card-a").parentElement?.style.transform).toContain("translate3d(0px, 112px"); + expect(getByTestId("card-b").parentElement?.style.transform).toContain("translate3d(272px, 112px"); + + clientWidth.mockRestore(); + offsetHeight.mockRestore(); + }); + it("renders nothing for an empty list", () => { const { container } = render(
} />); diff --git a/web/tests/memo-views.test.ts b/web/tests/memo-views.test.ts index 17eb37f3..d27eb297 100644 --- a/web/tests/memo-views.test.ts +++ b/web/tests/memo-views.test.ts @@ -5,6 +5,8 @@ import { BUILTIN_TASKS_VIEW_ID, getMemoScopePath, getMemoViewId, + getProfileUsername, + isMemoCollectionRoute, isMemoScopeRoute, resolveMemoScope, } from "@/lib/memo-views"; @@ -29,6 +31,18 @@ describe("memo scopes", () => { expect(getMemoScopePath("home")).toBe("/"); expect(getMemoScopePath("explore")).toBe("/explore"); }); + + it("treats user profiles as collection routes where views and filters apply in place", () => { + expect(isMemoCollectionRoute("/")).toBe(true); + expect(isMemoCollectionRoute("/archived")).toBe(true); + expect(isMemoCollectionRoute("/u/steven")).toBe(true); + expect(isMemoCollectionRoute("/u/steven/?view=map")).toBe(true); + expect(getProfileUsername("/u/j%C3%BAlia/")).toBe("júlia"); + expect(getProfileUsername("/u/steven/memos")).toBeUndefined(); + expect(isMemoScopeRoute("/u/steven")).toBe(false); + expect(isMemoCollectionRoute("/memos/123")).toBe(false); + expect(isMemoCollectionRoute("/attachments")).toBe(false); + }); }); describe("memo views", () => { diff --git a/web/tests/sidebar-row-state.test.tsx b/web/tests/sidebar-row-state.test.tsx index 53605786..d261f265 100644 --- a/web/tests/sidebar-row-state.test.tsx +++ b/web/tests/sidebar-row-state.test.tsx @@ -96,8 +96,13 @@ describe("MemoFilters", () => { expect(screen.getByText("Last week")).toBeInTheDocument(); }); - it("stays quiet about a view off the collection routes, where it does not apply", () => { + it("announces a view on a user profile, where it narrows that user's memos", () => { renderChips("/u/alice", BUILTIN_TASKS_VIEW_ID); + expect(screen.getByText("common.tasks")).toBeInTheDocument(); + }); + + it("stays quiet about a view off the collection routes, where it does not apply", () => { + renderChips("/attachments", BUILTIN_TASKS_VIEW_ID); expect(screen.queryByText("common.tasks")).not.toBeInTheDocument(); });