seansfkelley / nas-download-manager

An open source browser extension for adding/managing download tasks to your Synology DiskStation.
256 stars 46 forks source link

if background updates are disabled, performing an operation which changes the badge count then immediately closing the popup prevents the badge count from updating #129

Closed seansfkelley closed 4 years ago

seansfkelley commented 5 years ago

Most commonly: deleting a downloaded or just-finished task.

seansfkelley commented 4 years ago

This can't be fixed fully. When the popup closes, all the objects in the context are marked as dead, and any attempt to use them will throw an error in the console.

The request will complete, but callbacks will fail to execute. Given that the popup wants to know when the request completes so it can examine the response, there's no way we can make this work without polling.

Any solution to make this work will require shipping off much of the work to the background task through a message. If the popup didn't care about the response, this would be trivial. Since it does, we either need to implement polling, or make it not care.

seansfkelley commented 4 years ago

j/k, this can be fixed because sendMessage is allowed to return a promise for whatever the handler of the message responds with. Fixed in bb1b740badaea989a7baef8321464c6a54c7e753.