Skip to content

Commit

Permalink
Fix: new messages lines at correct location.
Browse files Browse the repository at this point in the history
  • Loading branch information
boxdot committed Jul 30, 2020
1 parent 51d4f0b commit 4c0adfd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ fn draw_messages<B: Backend>(f: &mut Frame<B>, app: &App, area: Rect) {

if let Some(selected_idx) = app.data.channels.state.selected() {
let unread_messages = app.data.channels.items[selected_idx].unread_messages;
if unread_messages > 0 {
if unread_messages > 0 && unread_messages < items.len() {
let prefix_width = max_username_width + 8;
let new_message_line = "-".repeat(prefix_width)
+ "new messages"
+ &"-".repeat((width as usize).saturating_sub(prefix_width));

items.insert(1, ListItem::new(Span::from(new_message_line)));
items.insert(unread_messages, ListItem::new(Span::from(new_message_line)));
}
}

Expand Down

0 comments on commit 4c0adfd

Please sign in to comment.