When user clicks the expand button, they see buttons like open in gmail. Put 2 buttons next to it that say Archive All and Delete All.
Let's start with Archive first. It's a quick copy and paste to make it work for delete too once the code has been approved for Archive.
When the buttons are clicked, we should run a bulk archive or delete. This should use archiveEmails([]) from QueueProvider.
If a user decides to close the page when we're still processing the batch, warn them that the bulk archive process hasn't finished yet. We can use beforeunload to do this. Even if the user does close the page though, we have the tasks stored in localStorage, so it will resume once they next visit the page.
Not all emails will be loaded by our UI, so this bulk script should be able to keep loading more and more emails to delete. Imagine there are 1500 emails from a heavy sender, and we've load them 500 at a time. We should keep archiving all of them till none remain. Take a look at app/api/user/bulk-archive/route.ts which can help here. But I think we can just load the thread ids into the client and rely on the existing queue there. To run the task on the server will require setting up a queueing system for that, which I don't want to touch this second.
When the Delete All button is clicked, make sure the user first confirms the action. Use confirm() for this.
What has to happen here:
open in gmail
. Put 2 buttons next to it that sayArchive All
andDelete All
.archiveEmails([])
fromQueueProvider
.beforeunload
to do this. Even if the user does close the page though, we have the tasks stored in localStorage, so it will resume once they next visit the page.app/api/user/bulk-archive/route.ts
which can help here. But I think we can just load the thread ids into the client and rely on the existing queue there. To run the task on the server will require setting up a queueing system for that, which I don't want to touch this second.confirm()
for this.Video of this task: https://www.loom.com/share/eec51a620d004114a403dd0e9f324a50