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