Skip to content

Commit

Permalink
feat(multiverse): add linked chunk debug screen in multiverse
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjbvr committed Dec 16, 2024
1 parent 34d15a4 commit cae7e43
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions labs/multiverse/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ enum DetailsMode {
#[default]
TimelineItems,
Events,
LinkedChunk,
}

struct Timeline {
Expand Down Expand Up @@ -517,13 +518,17 @@ impl App {
};
}

Char('l') => self.toggle_reaction_to_latest_msg().await,
Char('L') => self.toggle_reaction_to_latest_msg().await,

Char('r') => self.details_mode = DetailsMode::ReadReceipts,
Char('t') => self.details_mode = DetailsMode::TimelineItems,
Char('e') => self.details_mode = DetailsMode::Events,
Char('l') => self.details_mode = DetailsMode::LinkedChunk,

Char('b') if self.details_mode == DetailsMode::TimelineItems => {
Char('b')
if self.details_mode == DetailsMode::TimelineItems
|| self.details_mode == DetailsMode::LinkedChunk =>
{
self.back_paginate();
}

Expand Down Expand Up @@ -751,6 +756,29 @@ impl App {
}
}

DetailsMode::LinkedChunk => {
// In linked chunk mode, show a rough representation of the chunks.
match self.ui_rooms.lock().unwrap().get(&room_id).cloned() {
Some(room) => {
let lines = tokio::task::block_in_place(|| {
Handle::current().block_on(async {
let (cache, _drop_guards) = room
.event_cache()
.await
.expect("no event cache for that room");
cache.debug_string().await
})
});
render_paragraph(buf, lines.join("\n"));
}

None => render_paragraph(
buf,
"(room disappeared in the room list service)".to_owned(),
),
}
}

DetailsMode::Events => match self.ui_rooms.lock().unwrap().get(&room_id).cloned() {
Some(room) => {
let events = tokio::task::block_in_place(|| {
Expand Down Expand Up @@ -883,11 +911,14 @@ impl App {
"\nUse j/k to move, s/S to start/stop the sync service, m to mark as read, t to show the timeline, e to show events.".to_owned()
}
DetailsMode::TimelineItems => {
"\nUse j/k to move, s/S to start/stop the sync service, r to show read receipts, e to show events, Q to enable/disable the send queue, M to send a message.".to_owned()
"\nUse j/k to move, s/S to start/stop the sync service, r to show read receipts, e to show events, Q to enable/disable the send queue, M to send a message, L to like the last message.".to_owned()
}
DetailsMode::Events => {
"\nUse j/k to move, s/S to start/stop the sync service, r to show read receipts, t to show the timeline".to_owned()
}
DetailsMode::LinkedChunk => {
"\nUse j/k to move, s/S to start/stop the sync service, r to show read receipts, t to show the timeline, e to show events".to_owned()
}
}
};
Paragraph::new(content).centered().render(area, buf);
Expand Down

0 comments on commit cae7e43

Please sign in to comment.