Fix duplicate notifications by removing leftover WorkManager with different unique work name#6126
Conversation
…m before renaming the unique work name from WebSockManager to WebSocketManager
TimoPtr
left a comment
There was a problem hiding this comment.
Very nice finding! For clarity purpose please add documentation explaining why we do that and link it to your comment in the issue. Also this should be removed after some time from the codebase.
|
Thanks for the quick review, I added an explanation comment in 4cb2f69! Please check it out. Do you have any reliable way to schedule a reminder to remove it, preferably so that every contributor gets a notification through GitHub? I was thinking about scheduling an email response to this thread in Gmail, which should add a comment here. And what do you think about let's say 1 year from now, to give enough time for everyone to update? Or is 1 year too long? Or from another perspective, is there anything that's hurrying us to remove it, except for the risk of forgetting (which a scheduled notification solves)? |
We probably should create an issue with a due date. 1 year seems reasonable. Then in the code add a link to this issue. It's only important for anyone that might work on this code later and could remove it if doing some refactor or something instead of keeping the logic forever. |
app/src/main/kotlin/io/homeassistant/companion/android/websocket/WebsocketManager.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Timothy <[email protected]>
|
Nice, I didn't know GitHub allows you to set a due date on an issue! To prevent accidental removal of the |
I don't think it can but we can simply write it down in the issue. But don't worry let's keep it like this for now. |
Summary
Fixes #6066, where users were getting duplicate notifications over the persistent WebSocket connection. The bug was introduced in #5998, where the periodic WorkManager work request's unique name was renamed from
WebSockManagertoWebSocketManager. This change resulted in two periodic jobs, because the old one was still persisted, and scheduled to try to start every 15 minutes.I used the
App Inspectionfeature of Android Studio to see the list of WorkManager jobs, and I was able to capture this screenshot:Here you can see two instances of
WebsocketManagerrunning at the bottom of the list. Unfortunately this tool cannot show the unique name of the jobs, but the fact that two of the same type are running should be enough proof.Checklist
Any other notes