Skip to content

Commit cc5eca9

Browse files
authored
fix(app-shell): map raw sys_activity rows in the inbox Activity tab (#2781) (#2782)
1 parent 09062a7 commit cc5eca9

2 files changed

Lines changed: 45 additions & 3 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@object-ui/app-shell": patch
3+
---
4+
5+
fix(app-shell): map raw `sys_activity` rows before rendering the inbox Activity tab
6+
7+
The top-bar inbox bell's Activity tab (`InboxPopover`) rendered blank rows —
8+
only the relative time showed (`47m ·`), with the actor, summary, and object
9+
name all missing. `AppHeader.fetchPresenceAndActivities` cast the raw
10+
`sys_activity` rows straight to `ActivityItem` without renaming their fields,
11+
so the popover read `a.user` / `a.description` / `a.objectName` while the rows
12+
only carry plugin-audit's `actor_name` / `summary` / `object_name`.
13+
14+
The rows are now mapped onto `ActivityItem` (with `type` normalization, a
15+
`timestamp` fallback, and an empty-`summary` filter), mirroring the mapping in
16+
`useHomeInbox` so the bell and the Home dashboard stay in sync.

packages/app-shell/src/layout/AppHeader.tsx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,35 @@ export function AppHeader({
274274
return { data: [] as Record<string, unknown>[] };
275275
});
276276
if (activityResult.data?.length) {
277-
const items = (activityResult.data as Record<string, unknown>[]).filter(
278-
(a): a is ActivityItem & Record<string, unknown> => typeof a.type === 'string'
279-
);
277+
// Raw sys_activity rows use plugin-audit's column names
278+
// (summary / actor_name / object_name / timestamp). Map them onto
279+
// ActivityItem's shape (description / user / objectName) — casting the
280+
// raw row straight through left every field undefined, so the popover
281+
// Activity tab rendered blank rows (only the relative time showed).
282+
// Mirrors the mapping in `useHomeInbox` so the bell and Home never diverge.
283+
const items: ActivityItem[] = (activityResult.data as Record<string, unknown>[])
284+
.filter((r) => typeof r.type === 'string' && String(r.summary ?? '').trim())
285+
.map((r) => {
286+
let when = r.timestamp as string | undefined;
287+
if (!when || when === 'NOW()' || Number.isNaN(Date.parse(when))) {
288+
when = r.created_at as string | undefined;
289+
}
290+
const raw = String(r.type);
291+
const type: ActivityItem['type'] =
292+
raw === 'commented' || raw === 'mentioned' ? 'comment'
293+
: raw === 'deleted' ? 'delete'
294+
: raw === 'created' ? 'create'
295+
: 'update';
296+
return {
297+
id: String(r.id),
298+
type,
299+
objectName: (r.object_name as string) ?? '',
300+
recordId: (r.record_id as string) ?? undefined,
301+
user: (r.actor_name as string) ?? '',
302+
description: (r.summary as string) ?? '',
303+
timestamp: when ?? '',
304+
};
305+
});
280306
if (items.length) setApiActivities(items);
281307
}
282308
} catch { /* fallback below */ } finally {

0 commit comments

Comments
 (0)