Show unseen message count in room status info
This commit is contained in:
parent
f17d4459d1
commit
26923745ad
1 changed files with 17 additions and 7 deletions
|
|
@ -119,8 +119,8 @@ impl EuphRoom {
|
||||||
|
|
||||||
let status = self.status().await;
|
let status = self.status().await;
|
||||||
let chat = match &status {
|
let chat = match &status {
|
||||||
Some(Some(Status::Joined(joined))) => self.widget_with_nick_list(&status, joined),
|
Some(Some(Status::Joined(joined))) => self.widget_with_nick_list(&status, joined).await,
|
||||||
_ => self.widget_without_nick_list(&status),
|
_ => self.widget_without_nick_list(&status).await,
|
||||||
};
|
};
|
||||||
match &self.state {
|
match &self.state {
|
||||||
State::Normal => chat,
|
State::Normal => chat,
|
||||||
|
|
@ -144,10 +144,10 @@ impl EuphRoom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn widget_without_nick_list(&self, status: &Option<Option<Status>>) -> BoxedWidget {
|
async fn widget_without_nick_list(&self, status: &Option<Option<Status>>) -> BoxedWidget {
|
||||||
VJoin::new(vec![
|
VJoin::new(vec![
|
||||||
Segment::new(Border::new(
|
Segment::new(Border::new(
|
||||||
Padding::new(self.status_widget(status)).horizontal(1),
|
Padding::new(self.status_widget(status).await).horizontal(1),
|
||||||
)),
|
)),
|
||||||
// TODO Use last known nick?
|
// TODO Use last known nick?
|
||||||
Segment::new(self.chat.widget(String::new())).expanding(true),
|
Segment::new(self.chat.widget(String::new())).expanding(true),
|
||||||
|
|
@ -155,7 +155,7 @@ impl EuphRoom {
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn widget_with_nick_list(
|
async fn widget_with_nick_list(
|
||||||
&self,
|
&self,
|
||||||
status: &Option<Option<Status>>,
|
status: &Option<Option<Status>>,
|
||||||
joined: &Joined,
|
joined: &Joined,
|
||||||
|
|
@ -163,7 +163,7 @@ impl EuphRoom {
|
||||||
HJoin::new(vec![
|
HJoin::new(vec![
|
||||||
Segment::new(VJoin::new(vec![
|
Segment::new(VJoin::new(vec![
|
||||||
Segment::new(Border::new(
|
Segment::new(Border::new(
|
||||||
Padding::new(self.status_widget(status)).horizontal(1),
|
Padding::new(self.status_widget(status).await).horizontal(1),
|
||||||
)),
|
)),
|
||||||
Segment::new(self.chat.widget(joined.session.name.clone())).expanding(true),
|
Segment::new(self.chat.widget(joined.session.name.clone())).expanding(true),
|
||||||
]))
|
]))
|
||||||
|
|
@ -175,11 +175,12 @@ impl EuphRoom {
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn status_widget(&self, status: &Option<Option<Status>>) -> BoxedWidget {
|
async fn status_widget(&self, status: &Option<Option<Status>>) -> BoxedWidget {
|
||||||
// TODO Include unread message count
|
// TODO Include unread message count
|
||||||
let room = self.chat.store().room();
|
let room = self.chat.store().room();
|
||||||
let room_style = ContentStyle::default().bold().blue();
|
let room_style = ContentStyle::default().bold().blue();
|
||||||
let mut info = Styled::new(format!("&{room}"), room_style);
|
let mut info = Styled::new(format!("&{room}"), room_style);
|
||||||
|
|
||||||
info = match status {
|
info = match status {
|
||||||
None => info.then_plain(", archive"),
|
None => info.then_plain(", archive"),
|
||||||
Some(None) => info.then_plain(", connecting..."),
|
Some(None) => info.then_plain(", connecting..."),
|
||||||
|
|
@ -197,6 +198,15 @@ impl EuphRoom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let unseen = self.unseen_msgs_count().await;
|
||||||
|
if unseen > 0 {
|
||||||
|
info = info
|
||||||
|
.then_plain(" (")
|
||||||
|
.then(format!("{unseen}"), ContentStyle::default().bold().green())
|
||||||
|
.then_plain(")");
|
||||||
|
}
|
||||||
|
|
||||||
Text::new(info).into()
|
Text::new(info).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue