From 1fa35adae76fdbceb8f9a7d6c89d64e2d2febcab Mon Sep 17 00:00:00 2001 From: antifallobst Date: Sun, 9 Jul 2023 22:05:48 +0200 Subject: [PATCH] fix (ui): fixed rooms scroll out of bounds error and added more detail to 'not supported message like event' view in timeline --- src/app/event.rs | 16 ++++++++-------- src/ui/mod.rs | 5 ++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/app/event.rs b/src/app/event.rs index 9d0c8bc..f20417a 100644 --- a/src/app/event.rs +++ b/src/app/event.rs @@ -156,11 +156,11 @@ impl Event { .. } => { let i = match app.ui.rooms_state.selected() { - Some(i) => { - if i > 0 { - i - 1 + Some(cur) => { + if cur > 0 { + cur - 1 } else { - i + cur } } None => 0, @@ -173,11 +173,11 @@ impl Event { .. } => { let i = match app.ui.rooms_state.selected() { - Some(i) => { - if i < app.status.rooms().len() { - i + 1 + Some(cur) => { + if cur < app.status.rooms().len() - 1 { + cur + 1 } else { - i + cur } } None => 0, diff --git a/src/ui/mod.rs b/src/ui/mod.rs index f5b8a2a..9878c30 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -338,7 +338,10 @@ impl UI<'_> { (message_content.to_string(), Color::White) } _ => ( - "~~~ not supported message like event ~~~".to_string(), + format!( + "~~~ not supported message like event: {} ~~~", + message_like_event.event_type().to_string() + ), Color::Red, ), };