Proper In App notification implementation
Current behavior
The current implementation of InAppNotifications
is ugly and contains everything. It started as this small thing with just a close button, then gained an undo button, then a spinner, and then a bunch of methods to combine the above to fit whatever use case was needed. It also gained a timer
to control the interval at which it's callback was called.
This is terrible in all sorts of ways, it makes the widget inconstant with itself and leads to all sorts of ugly hacks, as there is no proper API to use it.
Expected behavior
We create a different widget per use-case with a clear API on how to use it. It should do nothing more than whats its required to achieve its task.
For example if we currently want to show an Error Message Notification, we only use the following features:
- A text label
- A close button
- Static timer to hide the notification
Stuff we don't use:
- Timed Regular callback
- Undo callback
- Undo button
- The spinner
Additional information
Currently we have 3 different types of notifications
Error message notification
This occurs when Import of an OPML file fails or when Gstreamer can't play a file. Its a simple label with a close button so it can be dismissed. It has a static timer to hide itself if it has not been dismissed till then.
Unsubscribe notification
This occurs when you unsubscribe from a Show. It consists of a close button, undo button and a label and a static timer. When the Unsubscribe action is triggered, the show is temporarily hidden and the Views are refreshed. An Unsub notification is created and shown then. It consist of a callback that runs when the notification has expired. This callback is what actually removes the Show from your library. If/when undo is pressed it cancels the regular callback, so you won't unsubscribe from the show, and resets the Views.
Update notification.
This notification is attached to an update operation. It consists of a label and a spinner. Its also not possible to dismiss. It's callback function is triggered frequently and polls a bounded(1)
channel, when it gets a message it means the background update is done, it hides the notifications and queues a refresh of Views.
Implementation Notes:
The notification widget used in other GNOME apps comes from libgd
, it worth investigating if it would feet our needs and if so generate Rust bindings fro the library.