Add "default_room" to profile settings (#25)

This commit is contained in:
Benjamin Große 2023-01-28 14:09:40 -08:00 committed by Ulyssa
parent b968d8c4a2
commit 4337be108b
No known key found for this signature in database
GPG key ID: 1B3965A3D18B9B64
3 changed files with 13 additions and 1 deletions

View file

@ -183,6 +183,7 @@ pub struct TunableValues {
pub typing_notice_send: bool, pub typing_notice_send: bool,
pub typing_notice_display: bool, pub typing_notice_display: bool,
pub users: UserOverrides, pub users: UserOverrides,
pub default_room: Option<String>,
} }
#[derive(Clone, Default, Deserialize)] #[derive(Clone, Default, Deserialize)]
@ -192,6 +193,7 @@ pub struct Tunables {
pub typing_notice_send: Option<bool>, pub typing_notice_send: Option<bool>,
pub typing_notice_display: Option<bool>, pub typing_notice_display: Option<bool>,
pub users: Option<UserOverrides>, pub users: Option<UserOverrides>,
pub default_room: Option<String>,
} }
impl Tunables { impl Tunables {
@ -202,6 +204,7 @@ impl Tunables {
typing_notice_send: self.typing_notice_send.or(other.typing_notice_send), typing_notice_send: self.typing_notice_send.or(other.typing_notice_send),
typing_notice_display: self.typing_notice_display.or(other.typing_notice_display), typing_notice_display: self.typing_notice_display.or(other.typing_notice_display),
users: merge_users(self.users, other.users), users: merge_users(self.users, other.users),
default_room: self.default_room.or(other.default_room),
} }
} }
@ -212,6 +215,7 @@ impl Tunables {
typing_notice_send: self.typing_notice_send.unwrap_or(true), typing_notice_send: self.typing_notice_send.unwrap_or(true),
typing_notice_display: self.typing_notice_display.unwrap_or(true), typing_notice_display: self.typing_notice_display.unwrap_or(true),
users: self.users.unwrap_or_default(), users: self.users.unwrap_or_default(),
default_room: self.default_room,
} }
} }
} }

View file

@ -138,7 +138,14 @@ impl Application {
let cmds = crate::commands::setup_commands(); let cmds = crate::commands::setup_commands();
let mut locked = store.lock().await; let mut locked = store.lock().await;
let win = IambWindow::open(IambId::Welcome, locked.deref_mut()).unwrap();
let win = settings
.tunables
.default_room
.and_then(|room| IambWindow::find(room, locked.deref_mut()).ok())
.or_else(|| IambWindow::open(IambId::Welcome, locked.deref_mut()).ok())
.unwrap();
let cmd = CommandBarState::new(IambBufferId::Command, locked.deref_mut()); let cmd = CommandBarState::new(IambBufferId::Command, locked.deref_mut());
let screen = ScreenState::new(win, cmd); let screen = ScreenState::new(win, cmd);

View file

@ -168,6 +168,7 @@ pub fn mock_dirs() -> DirectoryValues {
pub fn mock_tunables() -> TunableValues { pub fn mock_tunables() -> TunableValues {
TunableValues { TunableValues {
default_room: None,
read_receipt_send: true, read_receipt_send: true,
read_receipt_display: true, read_receipt_display: true,
typing_notice_send: true, typing_notice_send: true,