fix: let a plugin move a single message that is not in the open list

This commit is contained in:
Linus Rath
2026-10-26 11:29:37 +01:00
parent 8e66c9f6ad
commit e762943f7b
2 changed files with 15 additions and 1 deletions
@@ -81,6 +81,18 @@ describe('api.email.move and archive', () => {
expect(moveEmail).not.toHaveBeenCalled();
});
// An auto-filer moves new mail while the user looks at another folder.
it('moves a single message that is not in the open list', async () => {
const batchMoveEmails = vi.fn(async () => {});
const moveEmail = vi.fn(async () => {});
useAuthStore.setState({ client: { batchMoveEmails, moveEmail } as unknown as IJMAPClient });
useEmailStore.setState({ moveEmailsToMailbox: storeMove, emails: [] } as never);
await call(WRITER, 'email.move', ['m9'], 'arch');
expect([...batchMoveEmails.mock.calls, ...moveEmail.mock.calls]).toEqual([[['m9'], 'arch', undefined]]);
});
it('says when there is no Archive folder', async () => {
useEmailStore.setState({ mailboxes: [inbox] });
await expect(call(WRITER, 'email.archive', ['m1'])).rejects.toThrow(/no Archive folder/);
+3 -1
View File
@@ -4214,7 +4214,9 @@ export const useEmailStore = create<EmailStore>((set, get) => ({
}
return true;
}
if (emailIds.length === 1) {
// moveToMailbox acts on a listed row only; an id from elsewhere (a
// plugin moving new mail) takes the batch path, or it was dropped.
if (emailIds.length === 1 && get().emails.some(e => e.id === emailIds[0])) {
return await get().moveToMailbox(client, emailIds[0], destinationMailboxId);
}