renew: stage 4 #27
Labels
No labels
bug
critical
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Reference
kir68k/lattice#27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Focus: Implementing Sync actor + Supervisors
Notes
Sync actor
After login, the first thing to do would be setting up background sync, like in the old version and #19 (there it's done via
ExportApp::background_syncand a detached task).I already have
actor/syncas a port of that method.The nice thing about using a stream and intercepting sync
responses is possibly propagating the error to e.g. shut down any actors depending on bg sync
(which, from my understanding of the sdk, would be most functionality one would want).
That's what the comment in
while let Some(_res) = stream.next().await {// TODO: evaluate if the logic from gui branch should be added here}references.
In #19, the
background_syncmethod spawns two tasks; a sync stream as described, and a periodic (30s interval) check for cross-signing status:// spawned alongside the main sync task, every 30 seconds, this updates:// - all room data (see the RoomData type)// - cross-signing statuscx.spawn(|view: WeakEntity<Self>, cx: &mut AsyncApp| {let mut cx = cx.clone();async move {let mut roomdata_interval =async_time::interval(async_time::Duration::from_secs(30));roomdata_interval.set_missed_tick_behavior(async_time::MissedTickBehavior::Skip);loop {roomdata_interval.tick().await;let Some(client) = view.read_with(&cx, |view, _| view.user.client.clone())?else {break;};if let Some(upd) = client.encryption().cross_signing_status().await {view.update(&mut cx, |this, cx| {if upd.is_complete() {this.cross_status = CrossStatus::Active;} else if upd.has_master || upd.has_self_signing || upd.has_user_signing{this.cross_status = CrossStatus::Partial;} else {this.cross_status = CrossStatus::Inactive;}cx.notify();})?;}view.update(&mut cx, |this, cx| {this.update_all_rooms(true, cx);cx.notify();})?;}Worth porting over.
To do
The main thing to change for this issue is actually spawning
ClientSyncActorafter login. It requires a client, so login/restored session is required.Optionally, add messages, at least a
SyncError(e), and forward them to tuiLattice.Add a
SyncStatusenum like in #19, which should be rendered in e.g. a title bar, or status line, depending on the tui layout.Extras
In #19, the response is actually used:
match sync_response {Ok(_) => {let rooms = client.joined_rooms();view.update(&mut cx, |app, cx| {app.user.room_list = rooms;if app.sync_status != SyncStatus::Syncing {app.sync_status = SyncStatus::Syncing;}cx.notify();})?;}Err(e) => {let err = SharedString::from(e.to_string());view.update(&mut cx, |app, cx| {app.sync_status = SyncStatus::Error(err);cx.notify();})?;}}The UI responds to the sync state change, and displays either "Syncing", or "Sync error".
For now, the simplest is to just ignore the response.
Handling sync errors would come later on.
And the best would be implementing a TUI-friendly notification display system with its own actor. I like
nvim-notifya lot visually, so something similar to that would have to be implemented on the tui side.Supervisors
The currently added supervisors are:
/// Supervisor for chat-related functionality./// (rooms, timelines, search, indexing)pub chat: Option<ActorRef<ChatSupervisor>>,/// Supervisor for media-related functionality./// (uploads, downloads, caching, indexing)pub media: Option<ActorRef<MediaSupervisor>>,/// Supervisor for export-related functionality./// (export jobs)pub export: Option<ActorRef<ExportSupervisor>>,I can't exactly plan out what to call them, or if they'll be used at all, as of writing. That'll be decided later.
I think new supervisors/actors should come naturally when necessary, these are more like examples I added.