Commit 4337be108b

4337be108b7ea5bbb1500a2f0c5b458c65215833

parent: b968d8c4a2

Unregistered key

Benjamin Große <ste3ls@gmail.com> · 2023-01-28 22:09 UTC
committer: <git@ulyssa.dev>

Add "default_room" to profile settings (#25)

Layout: unified · split

src/config.rs +4
@@ -183,6 +183,7 @@ pub struct TunableValues {
183183 pub typing_notice_send: bool,
184184 pub typing_notice_display: bool,
185185 pub users: UserOverrides,
186 pub default_room: Option<String>,
186187}
187188
188189#[derive(Clone, Default, Deserialize)]
@@ -192,6 +193,7 @@ pub struct Tunables {
192193 pub typing_notice_send: Option<bool>,
193194 pub typing_notice_display: Option<bool>,
194195 pub users: Option<UserOverrides>,
196 pub default_room: Option<String>,
195197}
196198
197199impl Tunables {
@@ -202,6 +204,7 @@ impl Tunables {
202204 typing_notice_send: self.typing_notice_send.or(other.typing_notice_send),
203205 typing_notice_display: self.typing_notice_display.or(other.typing_notice_display),
204206 users: merge_users(self.users, other.users),
207 default_room: self.default_room.or(other.default_room),
205208 }
206209 }
207210
@@ -212,6 +215,7 @@ impl Tunables {
212215 typing_notice_send: self.typing_notice_send.unwrap_or(true),
213216 typing_notice_display: self.typing_notice_display.unwrap_or(true),
214217 users: self.users.unwrap_or_default(),
218 default_room: self.default_room,
215219 }
216220 }
217221}
src/main.rs +8 −1
@@ -138,7 +138,14 @@ impl Application {
138138 let cmds = crate::commands::setup_commands();
139139
140140 let mut locked = store.lock().await;
141 let win = IambWindow::open(IambId::Welcome, locked.deref_mut()).unwrap();
141
142 let win = settings
143 .tunables
144 .default_room
145 .and_then(|room| IambWindow::find(room, locked.deref_mut()).ok())
146 .or_else(|| IambWindow::open(IambId::Welcome, locked.deref_mut()).ok())
147 .unwrap();
148
142149 let cmd = CommandBarState::new(IambBufferId::Command, locked.deref_mut());
143150 let screen = ScreenState::new(win, cmd);
144151
src/tests.rs +1
@@ -168,6 +168,7 @@ pub fn mock_dirs() -> DirectoryValues {
168168
169169pub fn mock_tunables() -> TunableValues {
170170 TunableValues {
171 default_room: None,
171172 read_receipt_send: true,
172173 read_receipt_display: true,
173174 typing_notice_send: true,