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 { |
| 183 | 183 | pub typing_notice_send: bool, |
| 184 | 184 | pub typing_notice_display: bool, |
| 185 | 185 | pub users: UserOverrides, |
| 186 | pub default_room: Option<String>, |
| 186 | 187 | } |
| 187 | 188 | |
| 188 | 189 | #[derive(Clone, Default, Deserialize)] |
| @@ -192,6 +193,7 @@ pub struct Tunables { |
| 192 | 193 | pub typing_notice_send: Option<bool>, |
| 193 | 194 | pub typing_notice_display: Option<bool>, |
| 194 | 195 | pub users: Option<UserOverrides>, |
| 196 | pub default_room: Option<String>, |
| 195 | 197 | } |
| 196 | 198 | |
| 197 | 199 | impl Tunables { |
| @@ -202,6 +204,7 @@ impl Tunables { |
| 202 | 204 | typing_notice_send: self.typing_notice_send.or(other.typing_notice_send), |
| 203 | 205 | typing_notice_display: self.typing_notice_display.or(other.typing_notice_display), |
| 204 | 206 | users: merge_users(self.users, other.users), |
| 207 | default_room: self.default_room.or(other.default_room), |
| 205 | 208 | } |
| 206 | 209 | } |
| 207 | 210 | |
| @@ -212,6 +215,7 @@ impl Tunables { |
| 212 | 215 | typing_notice_send: self.typing_notice_send.unwrap_or(true), |
| 213 | 216 | typing_notice_display: self.typing_notice_display.unwrap_or(true), |
| 214 | 217 | users: self.users.unwrap_or_default(), |
| 218 | default_room: self.default_room, |
| 215 | 219 | } |
| 216 | 220 | } |
| 217 | 221 | } |
src/main.rs
+8 −1
| @@ -138,7 +138,14 @@ impl Application { |
| 138 | 138 | let cmds = crate::commands::setup_commands(); |
| 139 | 139 | |
| 140 | 140 | 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 | |
| 142 | 149 | let cmd = CommandBarState::new(IambBufferId::Command, locked.deref_mut()); |
| 143 | 150 | let screen = ScreenState::new(win, cmd); |
| 144 | 151 | |
src/tests.rs
+1
| @@ -168,6 +168,7 @@ pub fn mock_dirs() -> DirectoryValues { |
| 168 | 168 | |
| 169 | 169 | pub fn mock_tunables() -> TunableValues { |
| 170 | 170 | TunableValues { |
| 171 | default_room: None, |
| 171 | 172 | read_receipt_send: true, |
| 172 | 173 | read_receipt_display: true, |
| 173 | 174 | typing_notice_send: true, |