Implement a Status API
Let's start to brainstorm on a possible way to implement a Status API.
The fundamental objective of this is having a system that the GUI(/CLI) can connect to to make sure the user is informed about Flatsync's status.
This API should be structured as a Signal that the GUI(/CLI) can connect to.
The basic states should be the following:
Idle
Syncing
(The Remote is being pooled, this can be useful to make the Sync Now button dynamic
(Loading when a Sync is in process, this prevents spamming and gives some useful feedback))
While this would already improve the experience we need more, ideally we need to be able to handle and report most errors through this, the tricky part is making sure the state is properly combined.
In most cases, when an error presents, and the user must be informed, this error is also "fatal", meaning that it would prevent Syncing.
Therefore we could add a third state:
Error(DaemonError)
Where DaemonError
contains all "irrecoverable"/"manual intervention" errors (Invalid Token
,...)
Now, although this is much more complete already there are cases where something fails while not being fatal, an example might be pool_remote
that can fail to fetch the data. Although the syncing fails it's also true that this doesn't break the flow of execution.
We should therefore have a separate, independent, Warning(Option<DaemonWarning>)
that can contain a single DaemonWarning
such as SyncFailed
that would be dismissed by the user through something akin to a Toast/Notification interaction.
(This does add the extra complexity of having to comunicate back with the Daemon through some API)
This way we can correctly report the Status while being able to keep track of a single warning at the time which should be enough, at least for the current complexity.
Error States would also be informed through Toasts/Notifications but they wouldn't be dismissed by them (Hence why we need an Error
state that needs to be "solved").
This is just an early thought, if anyone has anything to add to this feel free to do so, any feedback is appreciated