feat: name the account the tray's unread list is from when several are signed in

This commit is contained in:
Linus Rath
2026-11-04 06:56:31 +01:00
parent 13272ad85d
commit 0729f05aeb
3 changed files with 17 additions and 1 deletions
+12
View File
@@ -490,6 +490,18 @@ describe('the summary', () => {
expect(summary.unread).toEqual([expect.objectContaining({ emailId: 'e1', accountId: 'acc', sender: 'Alice', subject: 'Lunch?' })]);
expect(JSON.parse(summary.unread[0].context!)).toMatchObject({ emailId: 'e1', slot: 3 });
expect(getEmails).toHaveBeenCalledWith('in', undefined, 5, 0, undefined, false, { notKeyword: '$seen' });
// One account: no need to say whose.
expect(summary.account).toBeUndefined();
});
it('with two accounts it names the one the unread mail is from', async () => {
const { useAccountStore } = await import('@/stores/account-store');
useAccountStore.setState({ accounts: [
{ id: 'alice@one', cookieSlot: 3, serverUrl: 'https://one.example', username: 'alice@example.org' },
{ id: 'bob@two', cookieSlot: 4, serverUrl: 'https://two.example', username: 'bob@example.org' },
] as never });
const { readSummary } = await import('../os-summary');
expect((await readSummary('en')).account).toBe('alice@example.org');
});
it('before the policy is known it is empty', async () => {
+3 -1
View File
@@ -81,7 +81,9 @@ export async function readSummary(locale: string | undefined, now = Date.now()):
const next = nextEventOf(events, now);
if (next) nextEvent = { title: next.title ?? '', when: formatEventTime(eventStart(next), now, locale) };
}
return { unread, recent, nextEvent };
// The tray lists one account's inbox: with more than one, it says whose.
const several = useAccountStore.getState().accounts.length > 1;
return { unread, recent, nextEvent, ...(several && entry.username ? { account: entry.username } : {}) };
}
/** Keeps main's copy current: when the unread count moves, and now and then for the next event. */
+2
View File
@@ -610,6 +610,8 @@ export interface DesktopOsSummary {
/** Newest conversations, whether read or not, for the jump list. */
recent: DesktopOsTrayMessage[];
nextEvent: { title: string; when: string } | null;
/** The account `unread` is from, when more than one is signed in. */
account?: string;
}
export type DesktopOsPowerEvent = 'suspend' | 'resume' | 'lock-screen' | 'unlock-screen';