Skip to content

Commit

Permalink
use separate state for disconnected chats
Browse files Browse the repository at this point in the history
  • Loading branch information
TicClick committed Oct 14, 2024
1 parent 5e2e857 commit f90d5e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/steel_core/src/chat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ pub enum ChatState {
Left,
JoinInProgress,
Joined,
Disconnected,
}

#[derive(Clone, Debug, Default)]
Expand Down
7 changes: 5 additions & 2 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl Application {
ConnectionStatus::InProgress | ConnectionStatus::Scheduled(_) => (),
ConnectionStatus::Disconnected { by_user } => {
for chat in self.state.chats.iter().cloned().collect::<Vec<String>>() {
self.change_chat_state(&chat, ChatState::Left);
self.change_chat_state(&chat, ChatState::Disconnected);
}
if self.state.settings.chat.reconnect && !by_user {
self.queue_reconnect();
Expand Down Expand Up @@ -428,13 +428,16 @@ impl Application {

match state {
ChatState::Left => {
self.send_system_message(chat, "You have left the chat (disconnected)")
self.send_system_message(chat, "You have left the chat")
}
ChatState::JoinInProgress => self.send_system_message(chat, "Joining the chat..."),
ChatState::Joined => match chat.is_channel() {
true => self.send_system_message(chat, "You have joined the chat"),
false => self.send_system_message(chat, "You have opened the chat"),
},
ChatState::Disconnected => {
self.send_system_message(chat, "You were disconnected from server");
}
}
}

Expand Down

0 comments on commit f90d5e1

Please sign in to comment.