Update euphoxide to version with id newtype wrappers
This commit is contained in:
parent
2d88513a28
commit
374c4c4f79
10 changed files with 131 additions and 114 deletions
|
|
@ -44,7 +44,7 @@ fn session_lines(mut text: Styled, session: &SessionView) -> Styled {
|
|||
line!(text, "name (raw)", session.name, debug);
|
||||
line!(text, "server_id", session.server_id);
|
||||
line!(text, "server_era", session.server_era);
|
||||
line!(text, "session_id", session.session_id);
|
||||
line!(text, "session_id", session.session_id.0);
|
||||
line!(text, "is_staff", session.is_staff, yes or no);
|
||||
line!(text, "is_manager", session.is_manager, yes or no);
|
||||
line!(
|
||||
|
|
@ -64,8 +64,8 @@ fn session_lines(mut text: Styled, session: &SessionView) -> Styled {
|
|||
}
|
||||
|
||||
fn message_lines(mut text: Styled, msg: &Message) -> Styled {
|
||||
line!(text, "id", msg.id);
|
||||
line!(text, "parent", msg.parent, optional);
|
||||
line!(text, "id", msg.id.0);
|
||||
line!(text, "parent", msg.parent.map(|p| p.0), optional);
|
||||
line!(text, "previous_edit_id", msg.previous_edit_id, optional);
|
||||
line!(text, "time", msg.time.0);
|
||||
line!(text, "encryption_key_id", &msg.encryption_key_id, optional);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::iter;
|
||||
|
||||
use crossterm::style::{Color, ContentStyle, Stylize};
|
||||
use euphoxide::api::{SessionType, SessionView, UserId};
|
||||
use euphoxide::api::{SessionId, SessionType, SessionView};
|
||||
use euphoxide::conn::Joined;
|
||||
use toss::styled::Styled;
|
||||
|
||||
|
|
@ -12,13 +12,13 @@ use crate::ui::widgets::list::{List, ListState};
|
|||
use crate::ui::widgets::text::Text;
|
||||
use crate::ui::widgets::BoxedWidget;
|
||||
|
||||
pub fn widget(state: &ListState<UserId>, joined: &Joined, focused: bool) -> BoxedWidget {
|
||||
pub fn widget(state: &ListState<SessionId>, joined: &Joined, focused: bool) -> BoxedWidget {
|
||||
let mut list = state.widget().focus(focused);
|
||||
render_rows(&mut list, joined);
|
||||
list.into()
|
||||
}
|
||||
|
||||
fn render_rows(list: &mut List<UserId>, joined: &Joined) {
|
||||
fn render_rows(list: &mut List<SessionId>, joined: &Joined) {
|
||||
let mut people = vec![];
|
||||
let mut bots = vec![];
|
||||
let mut lurkers = vec![];
|
||||
|
|
@ -49,7 +49,7 @@ fn render_rows(list: &mut List<UserId>, joined: &Joined) {
|
|||
}
|
||||
|
||||
fn render_section(
|
||||
list: &mut List<UserId>,
|
||||
list: &mut List<SessionId>,
|
||||
name: &str,
|
||||
sessions: &[&SessionView],
|
||||
own_session: &SessionView,
|
||||
|
|
@ -74,7 +74,7 @@ fn render_section(
|
|||
}
|
||||
}
|
||||
|
||||
fn render_row(list: &mut List<UserId>, session: &SessionView, own_session: &SessionView) {
|
||||
fn render_row(list: &mut List<SessionId>, session: &SessionView, own_session: &SessionView) {
|
||||
let (name, style, style_inv, perms_style_inv) = if session.name.is_empty() {
|
||||
let name = "lurk";
|
||||
let style = ContentStyle::default().grey();
|
||||
|
|
@ -111,7 +111,7 @@ fn render_row(list: &mut List<UserId>, session: &SessionView, own_session: &Sess
|
|||
.then(name, style_inv)
|
||||
.then(perms, perms_style_inv);
|
||||
list.add_sel(
|
||||
session.id.clone(),
|
||||
session.session_id.clone(),
|
||||
Text::new(normal),
|
||||
Background::new(Text::new(selected)).style(style_inv),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::collections::VecDeque;
|
|||
use std::sync::Arc;
|
||||
|
||||
use crossterm::style::{ContentStyle, Stylize};
|
||||
use euphoxide::api::{Data, Message, PacketType, SessionView, Snowflake, UserId};
|
||||
use euphoxide::api::{Data, Message, MessageId, PacketType, SessionId, SessionView};
|
||||
use euphoxide::conn::{Joined, Joining, Status};
|
||||
use parking_lot::FairMutex;
|
||||
use tokio::sync::oneshot::error::TryRecvError;
|
||||
|
|
@ -78,9 +78,9 @@ pub struct EuphRoom {
|
|||
popups: VecDeque<RoomPopup>,
|
||||
|
||||
chat: ChatState<euph::SmallMessage, EuphRoomVault>,
|
||||
last_msg_sent: Option<oneshot::Receiver<Snowflake>>,
|
||||
last_msg_sent: Option<oneshot::Receiver<MessageId>>,
|
||||
|
||||
nick_list: ListState<UserId>,
|
||||
nick_list: ListState<SessionId>,
|
||||
}
|
||||
|
||||
impl EuphRoom {
|
||||
|
|
@ -501,7 +501,7 @@ impl EuphRoom {
|
|||
if let RoomStatus::Connected(Status::Joined(joined)) = status {
|
||||
// TODO Fix euphoxide to use session_id as hash
|
||||
if let Some(id) = self.nick_list.cursor() {
|
||||
if id == joined.session.id {
|
||||
if id == joined.session.session_id {
|
||||
self.state = State::InspectSession(joined.session.clone());
|
||||
} else if let Some(session) = joined.listing.get(&id) {
|
||||
self.state = State::InspectSession(session.clone());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue