Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ apps/api/uploads/

# Entorno local personal (scripts, seeds, docker extra) — no subir al repo
.local/

# Local git worktrees for parallel agent work — never commit
.worktrees/
26 changes: 10 additions & 16 deletions apps/web/src/components/organisms/app-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Link from 'next/link';
import { api } from '@/lib/api';
import { getToken, authHeaders, loginHref as buildLoginHref } from '@/lib/auth';
import { loginHref as buildLoginHref } from '@/lib/auth';
import { getT } from '@/i18n/server';
import { getMe, getNotificationUnread } from '@/lib/navigation-data';
import { BrandLogo } from '@/components/molecules/brand-logo';
import { LanguageSwitcher } from '@/components/molecules/language-switcher';
import { AccountControl } from '@/components/molecules/account-control';
Expand All @@ -28,20 +28,14 @@ const STATUS_DOT: Record<'active' | 'paused' | 'closed', string> = {
export async function AppBar({ variant, slug, emergency, backHref }: AppBarProps) {
const { t } = await getT();
const ta = t.appbar;
const token = await getToken();

let user: { name: string; email: string; isAdmin: boolean } | null = null;
let unreadCount = 0;
if (token != null) {
const [meRes, notifRes] = await Promise.all([
api.GET('/auth/me', { headers: authHeaders(token) }),
api.GET('/notifications/mine', { headers: authHeaders(token) }),
]);
if (meRes.data != null) {
user = { name: meRes.data.name, email: meRes.data.email, isAdmin: meRes.data.isAdmin === true };
}
if (notifRes.data != null) unreadCount = notifRes.data.unreadCount;
}

// getMe()/getNotificationUnread() are wrapped in React `cache()` (see
// navigation-data.ts), so this dedupes with any other consumer that reads
// the same principal/notifications data within this request instead of
// re-hitting /auth/me and /notifications/mine per page (#277).
const [me, unreadCount] = await Promise.all([getMe(), getNotificationUnread()]);
const user =
me != null ? { name: me.name, email: me.email, isAdmin: me.isAdmin === true } : null;

const currentPath = slug != null ? `/e/${slug}` : '/';
const loginHref = buildLoginHref(currentPath);
Expand Down
Loading