Closed gudmundurg74 closed 7 years ago
I made a workaround in #93 for this which turned out to be incomplete. Should that be removed? Or perhaps keep it until the queueing mechanism gets the ability to reorder commands to minimize unnecessary SELECTs.
That looks like a feature to group commands of a single mailbox behind a selectMailbox, I think we should just keep it, like you say, until we optimize the queue.
The _selectedMailbox check in the precheck functions does not take into account any potential SELECT commands on the queue or currently running, it only checks what is currently selected. So this here also checks the queue and anything currently running, looking for the last SELECT to run before the precheck's command should run.
See the integration test for a reproduction of the problem: box A is originally selected. Then a request to select B is sent, while that request is under way a setFlags in A is requested. A is still selected so the selectMailbox precheck does not fire. B gets selected and setFlags is then run there instead of A.