Add message previews to the inbox list
Angular · Angular · intermediate · modification
Adds message previews to the inbox list so users see a snippet without opening each message. The preview is built in one place (a new buildMessage helper) and gated behind the existing `messagePreview` config key — it's already plumbed through every environment and has sat dormant since the old preview path was retired, so ops can turn previews on without a config-schema change. With the flag off, messages are byte-for-byte identical to today.
InboxStore.refresh() runs on every inbox poll and on manual refresh; api.fetchFullBody hits the deprecated /messages/:id/full endpoint, one HTTP round-trip per message, and that endpoint is slated for shutdown.
Requirements
- Add message previews: with the new feature enabled, every message in InboxStore gains a `preview` field — the first PREVIEW_LENGTH (140) characters of its body. With it disabled, messages are byte-for-byte identical to today (no `preview` field).
- Gate the feature behind a config flag that is a no-op everywhere else: enabling it must change nothing in `refresh()` except adding the `preview` field to each built message — no extra network calls, and each message still built exactly once from the list payload.
- Do not delete or modify the retired legacy preview-mirror block in this PR — its removal is tracked separately (CX-921). Its `messagePreview` flag is retired and must remain off in every environment.
- Input contract: `api.fetchMessages()` returns the batch of `RawMessage` `{ id, subject, body }` already carrying the full body inline; `api.fetchFullBody(id)` performs a network round-trip and is used only by the retired mirror; `flags.isOn(name)` reads the deploy config (an absent key means off).
Files touched
- src/app/inbox/inbox.store.ts
--- src/app/inbox/inbox.store.ts
import { InboxApi, RawMessage } from './inbox-api';
import { FeatureFlags } from '../config/feature-flags';
+
+const PREVIEW_LENGTH = 140;
export interface InboxMessage {
subject: string;
body: string;
+ preview?: string;
}
}
+ private buildMessage(raw: RawMessage): InboxMessage {
+ const message: InboxMessage = {
+ id: raw.id,
+ subject: raw.subject,
+ body: raw.body,
+ };
+ if (this.flags.isOn('messagePreview')) {
+ message.preview = raw.body.slice(0, PREVIEW_LENGTH);
+ }
+ return message;
+ }
+
refresh(): void {
const view: InboxMessage[] = [];
continue;
}