Open tjmtic opened 1 month ago
Moved error handling responsibilities to a delegate implementation, and then added dependency injection for app and testing.
Now, this more closely resembles the implementation of the offline status, and is more generalized and reusable as a message handler. Delegation seemed more appropriate than passing an instance to avoid exposing that instance or redeclaring the add/remove message functions.
How about integrating the snackbars related to Bookmark and Network statuses as well? Additionally, if there is an object that manages the error types, it might make writing test codes easier. 🤔
Updated the implementation with Bookmarks and Network statuses.
@yongsuk44 can you describe more what you mean about the object managing error types?
Fixes #1435 Fixes #1068
Added error messages to AppState to be displayed via Snackbar ( per this conversation ), and implementation for the custom tab launch failed error as described.
Also added simple tests for error list order functionality.
Now, the errorHandler can be passed to the Route level from NiaApp, and define specific errors to pass at the Screen level. This could be implemented on a per screen/viewmodel basis, but this works as a single source of truth for snackbar-bound errors.
LaunchedEffect on first error message, which prevents flickering from the LaunchedEffect when modifying the list of messages. ErrorMessage data class for IDs, which prevents duplicate messages from preventing the LaunchedEffect firing. I will be curious if there is a specific flow based solution to this issue.
The Offline message is still a separate Launched effect due to the value, however the snackbar handles the interaction at that point, so I believe this is the intended approach for general errors.