Closed Bug 1583783 Opened 5 years ago Closed 3 years ago

Chaining mark as read and moving to a different folder doesn't mark as read

Categories

(Thunderbird :: Add-Ons: Extensions API, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: Fallen, Unassigned)

Details

I'm chaining the operations to mark as read and then move into a different folder. Marking as read works great on its own, as does moving to a different folder. What doesn't work is both together. The messages are unread in the new folder.

async function* selectedMessagePages() {
  let page = await browser.mailTabs.getSelectedMessages();
  if (page.messages.length) {
    yield page.messages;
  }

  while (page.id) {
    page = await browser.messages.continueList(page.id);
    yield page.messages;
  }
}

async function run(folder) {
  for await (let messages of selectedMessagePages()) {
    let ids = messages.map(message => message.id);
    await browser.messages.move(ids, folder);
    await Promise.all(ids.map(id => browser.messages.update(id, { read: true })));
  }
}

I've also tried to switch the order of the move and the mark as read. Geoff, any idea what is going on here?

(as a side note, we should make messages.update() accept both a message id or an array of message ids, but I can file a separate bug for this)

Flags: needinfo?(geoff)

I think this is failing because moved messages get new IDs. Doing it in the other order should work, but I wonder if there's something async about recording the change that happens too slowly before the move.

Flags: needinfo?(geoff)

Is this fixed now after bug 1631184?

Flags: needinfo?(philipp)
Status: NEW → RESOLVED
Closed: 3 years ago
Flags: needinfo?(philipp)
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.