mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-04 16:14:07 +00:00
feat: name the account the tray's unread list is from when several are signed in
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user