mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-19 21:29:52 -07:00
Add "default_room" to profile settings (#25)
This commit is contained in:
parent
b968d8c4a2
commit
4337be108b
3 changed files with 13 additions and 1 deletions
|
@ -183,6 +183,7 @@ pub struct TunableValues {
|
|||
pub typing_notice_send: bool,
|
||||
pub typing_notice_display: bool,
|
||||
pub users: UserOverrides,
|
||||
pub default_room: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Deserialize)]
|
||||
|
@ -192,6 +193,7 @@ pub struct Tunables {
|
|||
pub typing_notice_send: Option<bool>,
|
||||
pub typing_notice_display: Option<bool>,
|
||||
pub users: Option<UserOverrides>,
|
||||
pub default_room: Option<String>,
|
||||
}
|
||||
|
||||
impl Tunables {
|
||||
|
@ -202,6 +204,7 @@ impl Tunables {
|
|||
typing_notice_send: self.typing_notice_send.or(other.typing_notice_send),
|
||||
typing_notice_display: self.typing_notice_display.or(other.typing_notice_display),
|
||||
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_display: self.typing_notice_display.unwrap_or(true),
|
||||
users: self.users.unwrap_or_default(),
|
||||
default_room: self.default_room,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,7 +138,14 @@ impl Application {
|
|||
let cmds = crate::commands::setup_commands();
|
||||
|
||||
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 screen = ScreenState::new(win, cmd);
|
||||
|
||||
|
|
|
@ -168,6 +168,7 @@ pub fn mock_dirs() -> DirectoryValues {
|
|||
|
||||
pub fn mock_tunables() -> TunableValues {
|
||||
TunableValues {
|
||||
default_room: None,
|
||||
read_receipt_send: true,
|
||||
read_receipt_display: true,
|
||||
typing_notice_send: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue