Automatically delete 'stale'/old widgets from database #2702
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Automatically deletes widgets from the database that are no longer bound to the widget provider but that are still in the database when asked to update all widgets. This will remove unnecessary updates (and websocket connections!) due to 'stale'/old widgets that aren't exposed to the user. The PR also removes the "Delete widget" button on the widget configuration screen as it is no longer required.
No issue to link here, but "remove unused widgets from Settings > Companion app > Manage Widgets" has been a 'solution' for multiple issues in the past.
Screenshots
The "Delete widget" button has been removed when updating a widget:
Link to pull request in Documentation repository
n/a, the documentation didn't mention the delete functionality
Any other notes
Testing to make sure widgets aren't accidentally deleted: I've been running this code for a few hours now and tried several things to imitate running it for a longer period of time (manually triggering doze, killing the launcher, rebooting a few times).