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.
This commit is contained in:
johnnyjoygh 2026-09-05 00:22:05 +08:00
parent dfa0fda766
commit 55d8e6ad42
62 changed files with 274 additions and 217 deletions

View file

@ -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 }) =>
<div className={SIDEBAR_SECTION_STACK_CLASSES}>
{context === "profile" && <ProfileMode />}
<SidebarSection ariaLabel={t("common.statistics")}>
<StatisticsView statisticsData={statistics} navigationTarget={filterTarget} onDateSelect={() => setMobileOpen(false)} />
<StatisticsView statisticsData={statistics} onDateSelect={() => setMobileOpen(false)} />
</SidebarSection>
{showViews && <ViewsSection />}
<TagsSection tagCount={tags} navigationTarget={filterTarget} scope={tagStateScope} onSelect={() => setMobileOpen(false)} />
{/* Every collection route narrows the same way: views (yours, so signed-in only), days, tags. */}
{currentUser && <ViewsSection />}
<TagsSection tagCount={tags} scope={tagStateScope} onSelect={() => setMobileOpen(false)} />
</div>
);
};

View file

@ -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);

View file

@ -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<string, number>;
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<boolean>("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);

View file

@ -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);
};

View file

@ -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";

View file

@ -10,6 +10,8 @@ interface ColumnGridProps<T> {
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<T> {
}
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<T>({
renderItem,
estimateHeight,
leading,
header,
priorityKey,
maxColumns,
maxColumnWidth,
@ -105,7 +109,15 @@ function ColumnGrid<T>({
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<T>({
// 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<string, number>();
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<string>([LEADING_KEY]);
if (priorityKey) {
@ -154,7 +171,7 @@ function ColumnGrid<T>({
},
});
const columnY = new Array<number>(count).fill(0);
const columnY = new Array<number>(count).fill(columnStartY);
const pos = new Map<string, { x: number; y: number }>();
for (const { key } of ordered) {
const col = columnOf.get(key) ?? 0;
@ -265,6 +282,13 @@ function ColumnGrid<T>({
return (
<div ref={containerRef} className="relative w-full" style={{ height: containerHeight }}>
{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.
<div key={HEADER_KEY} ref={getItemRef(HEADER_KEY)} className="absolute top-0 left-0">
{header}
</div>
)}
{leading != null && (
// Positioned with left/top (see relayout), and deliberately WITHOUT
// transform/will-change so it never establishes a containing block that would trap

View file

@ -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) => {

View file

@ -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);

View file

@ -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 ? (
<Placeholder variant="empty" message={t("message.no-data")} className="w-full" />
<Placeholder variant="empty" message={props.emptyMessage ?? t("message.no-data")} className="w-full" />
) : null;
const initialLoader = isDisplayPending && showLoader ? <Loader /> : 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}
<MemoFilters className="mb-2" />
{initialLoader}

View file

@ -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;

View file

@ -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;

View file

@ -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) {

View file

@ -257,8 +257,7 @@
"restored-successfully": "تمت الاستعادة بنجاح",
"succeed-copy-content": "تم نسخ المحتوى بنجاح.",
"succeed-copy-link": "تم نسخ الرابط بنجاح.",
"update-succeed": "تم التحديث بنجاح",
"user-not-found": "المستخدم غير موجود"
"update-succeed": "تم التحديث بنجاح"
},
"reference": {
"add-references": "إضافة مراجع",

View file

@ -328,8 +328,7 @@
"restored-successfully": "Възстановен успешно",
"succeed-copy-content": "Съдържанието е копирано успешно.",
"succeed-copy-link": "Връзката е копирана успешно.",
"update-succeed": "Актуализацията е успешна",
"user-not-found": "Потребителят не е намерен"
"update-succeed": "Актуализацията е успешна"
},
"reference": {
"add-references": "Добавете препратки",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -328,8 +328,7 @@
"restored-successfully": "Έγινε επαναφορά με επιτυχία",
"succeed-copy-content": "Το περιεχόμενο αντιγράφηκε με επιτυχία.",
"succeed-copy-link": "Ο σύνδεσμος αντιγράφηκε με επιτυχία.",
"update-succeed": "Η ενημέρωση ολοκληρώθηκε με επιτυχία",
"user-not-found": "Ο χρήστης δεν βρέθηκε"
"update-succeed": "Η ενημέρωση ολοκληρώθηκε με επιτυχία"
},
"reference": {
"add-references": "Προσθήκη παραπομπών",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -257,8 +257,7 @@
"restored-successfully": "با موفقیت بازیابی شد",
"succeed-copy-content": "محتوا با موفقیت کپی شد.",
"succeed-copy-link": "پیوند با موفقیت کپی شد.",
"update-succeed": "بروزرسانی موفق بود",
"user-not-found": "کاربر یافت نشد"
"update-succeed": "بروزرسانی موفق بود"
},
"reference": {
"add-references": "افزودن منابع",

View file

@ -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ä",

View file

@ -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",

View file

@ -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",

View file

@ -454,8 +454,7 @@
"restored-successfully": "שוחזר בהצלחה",
"succeed-copy-content": "התוכן הועתק בהצלחה.",
"succeed-copy-link": "הקישור הועתק בהצלחה.",
"update-succeed": "העדכון הצליח",
"user-not-found": "המשתמש לא נמצא"
"update-succeed": "העדכון הצליח"
},
"reference": {
"add-references": "הוסף הפניות",

View file

@ -257,8 +257,7 @@
"restored-successfully": "सफलतापूर्वक पुनर्स्थापित किया गया",
"succeed-copy-content": "सामग्री सफलतापूर्वक कॉपी की गई।",
"succeed-copy-link": "लिंक सफलतापूर्वक कॉपी किया गया।",
"update-succeed": "अपडेट सफल हुआ",
"user-not-found": "उपयोगकर्ता नहीं मिला"
"update-succeed": "अपडेट सफल हुआ"
},
"reference": {
"add-references": "संदर्भ जोड़ें",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -365,8 +365,7 @@
"restored-successfully": "復元しました",
"succeed-copy-content": "コンテンツのコピーに成功しました。",
"succeed-copy-link": "リンクのコピーに成功しました。",
"update-succeed": "変更は保存されました",
"user-not-found": "ユーザーが見つかりませんでした"
"update-succeed": "変更は保存されました"
},
"reference": {
"add-references": "参照を追加",

View file

@ -291,8 +291,7 @@
"restored-successfully": "წარმატებით აღდგა",
"succeed-copy-content": "კონტენტი წარმატებით კოპირდა.",
"succeed-copy-link": "ლინკი წარმატებით კოპირდა.",
"update-succeed": "განახლება წარმატებით დასრულდა",
"user-not-found": "მომხმარებელი ვერ მოიძებნა"
"update-succeed": "განახლება წარმატებით დასრულდა"
},
"reference": {
"add-references": "რეფერენციის დამატება",

View file

@ -257,8 +257,7 @@
"restored-successfully": "성공적으로 복구했습니다",
"succeed-copy-content": "콘텐츠를 클립보드에 복사했습니다.",
"succeed-copy-link": "링크를 클립보드에 복사했습니다.",
"update-succeed": "업데이트 성공",
"user-not-found": "회원을 찾을 수 없습니다"
"update-succeed": "업데이트 성공"
},
"reference": {
"add-references": "참조 추가",

View file

@ -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",

View file

@ -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",

View file

@ -257,8 +257,7 @@
"restored-successfully": "यशस्वीरित्या पुनर्संचयित केले",
"succeed-copy-content": "सामग्री यशस्वीरित्या कॉपी केली.",
"succeed-copy-link": "लिंक यशस्वीरित्या कॉपी केली.",
"update-succeed": "अपडेट यशस्वी झाले",
"user-not-found": "वापरकर्ता सापडला नाही"
"update-succeed": "अपडेट यशस्वी झाले"
},
"reference": {
"add-references": "संदर्भ जोडा",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -385,8 +385,7 @@
"restored-successfully": "Успешно восстановлено.",
"succeed-copy-content": "Контент успешно скопирован.",
"succeed-copy-link": "Ссылка скопирована в буфер обмена.",
"update-succeed": "Успешно обновлено",
"user-not-found": "Пользователь не найден"
"update-succeed": "Успешно обновлено"
},
"reference": {
"add-references": "Добавить связь",

View file

@ -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",

View file

@ -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",

View file

@ -328,8 +328,7 @@
"restored-successfully": "Успешно враћено",
"succeed-copy-content": "Садржај је успешно копиран.",
"succeed-copy-link": "Линк је успешно копиран.",
"update-succeed": "Ажурирање је успело",
"user-not-found": "Корисник није пронађен"
"update-succeed": "Ажурирање је успело"
},
"reference": {
"add-references": "Додајте референце",

View file

@ -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",

View file

@ -257,8 +257,7 @@
"restored-successfully": "กู้คืนเรียบร้อยแล้ว",
"succeed-copy-content": "คัดลอกเนื้อหาเรียบร้อยแล้ว",
"succeed-copy-link": "คัดลอกลิงก์เรียบร้อยแล้ว",
"update-succeed": "อัปเดตเรียบร้อยแล้ว",
"user-not-found": "ไม่พบผู้ใช้งาน"
"update-succeed": "อัปเดตเรียบร้อยแล้ว"
},
"reference": {
"add-references": "เพิ่มข้อมูลอ้างอิง",

View file

@ -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",

View file

@ -291,8 +291,7 @@
"restored-successfully": "Успішно відновлено",
"succeed-copy-content": "Вміст успішно скопійовано.",
"succeed-copy-link": "Посилання успішно скопійовано.",
"update-succeed": "Оновлення успішне",
"user-not-found": "Користувача не знайдено"
"update-succeed": "Оновлення успішне"
},
"reference": {
"add-references": "Додати посилання",

View file

@ -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",

View file

@ -386,8 +386,7 @@
"restored-successfully": "恢复成功",
"succeed-copy-content": "复制内容到剪贴板成功。",
"succeed-copy-link": "复制链接到剪贴板成功。",
"update-succeed": "更新成功",
"user-not-found": "未找到该用户"
"update-succeed": "更新成功"
},
"reference": {
"add-references": "添加引用",

View file

@ -459,8 +459,7 @@
"restored-successfully": "還原成功",
"succeed-copy-content": "內容複製到剪貼簿成功。",
"succeed-copy-link": "複製連結到剪貼簿成功。",
"update-succeed": "更新成功",
"user-not-found": "未找到該使用者"
"update-succeed": "更新成功"
},
"reference": {
"add-references": "引用參考資料",

View file

@ -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 }) => (
<div className="border-b border-border/10 px-4 py-8 sm:px-6">
<div className="mx-auto flex max-w-2xl gap-4 sm:gap-6">
<UserAvatar className="h-20 w-20 shrink-0 rounded-2xl shadow-sm sm:h-24 sm:w-24" avatarUrl={user.avatarUrl} />
<div className="flex flex-1 flex-col gap-3">
<div>
<h1 className="text-2xl font-bold text-foreground sm:text-3xl">{user.displayName || user.username}</h1>
{user.displayName && <p className="text-sm text-muted-foreground">@{user.username}</p>}
</div>
{user.description && <p className="text-sm text-foreground/70">{user.description}</p>}
<Button variant="outline" size="sm" onClick={onCopyProfileLink} className="w-fit gap-2">
<ExternalLinkIcon className="h-4 w-4" />
{shareLabel}
</Button>
</div>
</div>
// 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 }) => (
<div className={cn("flex w-full items-start gap-3", className)}>
{avatar}
<div className="min-w-0 flex-1">{children}</div>
</div>
);
// The list's header, so in grid mode it spans every column.
const ProfileHeader = ({ user, className }: { user: User; className?: string }) => (
<IdentityRow className={className} avatar={<UserAvatar className={PROFILE_AVATAR_SLOT_CLASSES} avatarUrl={user.avatarUrl} />}>
<div className="flex min-w-0 flex-wrap items-baseline gap-x-2">
<h1 className={cn("truncate", PROFILE_TITLE_CLASSES)}>{user.displayName || user.username}</h1>
{user.displayName && <span className="text-ui text-muted-foreground">@{user.username}</span>}
</div>
{user.description && <p className="mt-0.5 line-clamp-2 max-w-[60ch] text-ui text-muted-foreground">{user.description}</p>}
</IdentityRow>
);
const ProfileHeaderSkeleton = () => (
<div aria-busy="true">
<IdentityRow avatar={<span className={cn(PROFILE_AVATAR_SLOT_CLASSES, "animate-pulse bg-muted")} />}>
<span className="mt-1 block h-5 w-40 animate-pulse rounded bg-muted" />
<span className="mt-2 block h-3.5 w-3/5 animate-pulse rounded bg-muted" />
</IdentityRow>
</div>
);
const ProfileNotFound = ({ username }: { username: string }) => {
const t = useTranslate();
return (
<IdentityRow
avatar={
<span
className={cn(PROFILE_AVATAR_SLOT_CLASSES, "grid place-items-center border border-dashed border-input text-muted-foreground/60")}
>
<UserRoundIcon className="size-5" strokeWidth={1.6} />
</span>
}
>
<h1 className={PROFILE_TITLE_CLASSES}>{t("profile.not-found-title")}</h1>
<p className="mt-0.5 max-w-[60ch] text-ui text-muted-foreground">{t("profile.not-found-description", { username })}</p>
<Link to={ROUTES.EXPLORE} className="mt-3 block w-fit text-ui text-primary hover:underline">
{t("common.explore")}
</Link>
</IdentityRow>
);
};
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 (
<PagedMemoList
renderer={(memo: Memo, { compact }) => (
<MemoView key={getMemoKey(memo)} memo={memo} showVisibility showPinned showSpace compact={compact} />
)}
listSort={listSort}
orderBy={orderBy}
filter={memoFilter}
emptyMessage={isOwner ? undefined : t("profile.no-shared-memos", { username: user.username })}
renderHeader={({ useGrid }) => <ProfileHeader user={user} className={useGrid ? undefined : "mb-4"} />}
/>
);
}
// Everything that is not the list shares the list's single-column reading rail.
return (
<section className="flex min-h-screen w-full flex-col bg-background">
{user ? (
<>
<ProfileHeader user={user} onCopyProfileLink={handleCopyProfileLink} shareLabel={t("common.share")} />
<div className="mt-4 flex-1">
<div className="mx-auto w-full max-w-2xl">
{activeTab === "memos" ? (
<PagedMemoList
renderer={(memo: Memo, { compact }) => (
<MemoView key={getMemoKey(memo)} memo={memo} showVisibility showPinned showSpace compact={compact} />
)}
listSort={listSort}
orderBy={orderBy}
filter={memoFilter}
/>
) : (
<div className="">
<Suspense fallback={<div className="h-[60dvh] sm:h-[500px] rounded-xl border border-border bg-muted/30" />}>
<UserMemoMap creator={user.name} className="h-[60dvh] sm:h-[500px] rounded-xl" />
</Suspense>
</div>
)}
</div>
</div>
</>
<section className="mx-auto flex w-full max-w-2xl flex-col gap-4">
{isLoading ? (
showSkeleton && <ProfileHeaderSkeleton />
) : !user ? (
<ProfileNotFound username={username} />
) : (
<div className="flex flex-1 items-center justify-center">
<p className="text-muted-foreground">{t("message.user-not-found")}</p>
</div>
<>
<ProfileHeader user={user} />
<Suspense fallback={<div className="h-[60dvh] rounded-xl border border-border bg-muted/30 sm:h-[500px]" />}>
<UserMemoMap creator={user.name} className="h-[60dvh] rounded-xl sm:h-[500px]" />
</Suspense>
</>
)}
</section>
);

View file

@ -84,7 +84,7 @@ export const routeConfig: RouteObject[] = [
children: [{ path: Routes.ABOUT, element: <About /> }],
},
{ path: Routes.EXPLORE, element: <Explore /> },
{ path: "u/:username", element: <UserProfile /> },
{ path: Routes.USER_PROFILE, element: <UserProfile /> },
{
element: <RequireAuthRoute />,
children: [

View file

@ -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",

View file

@ -37,6 +37,31 @@ describe("<ColumnGrid>", () => {
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(
<ColumnGrid
items={[item("a"), item("b")]}
getKey={getKey}
renderItem={(i) => <div data-testid={`card-${i.id}`}>{i.id}</div>}
header={<div data-testid="identity" />}
/>,
);
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(<ColumnGrid items={[]} getKey={getKey} renderItem={() => <div data-testid="card" />} />);

View file

@ -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", () => {

View file

@ -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();
});