Skip to content

Clear mark-as-read queue when active account changes #5557

Open
@gnprice

Description

@gnprice

@chrisbobbe pointed out on #5552 that in queueMarkAsRead.js, where we keep a queue of messages the user wants to mark as read:

[…] there's also the flaw where we're storing per-account state at a module's toplevel:

let unsentMessageIds: number[] = [];
let lastSentTime = -Infinity;
let timeout = null;

This is similar to #5009, in that it means that we have ongoing activity which is meant for the particular account that's currently active, and when the active account changes we may start treating it as if it were meant for the new active account.

Instead, much like the solution described in #5009: when we go to process this queue, we should check if the account we're about to act for is the same one that the existing queue was meant for, if it's nonempty. If not, we should discard the existing contents of the queue.

In the future as part of #5005, this will naturally get resolved because we'll have potentially several mark-as-read queues active where we're trying to mark messages as read on several different accounts. But there's no need to wait for that.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions