fix: replace assert! calls in UI activities with graceful error handling

This commit is contained in:
Christian Visintin
2026-02-27 22:27:14 +01:00
parent be237c39a6
commit 4fdaf82314
9 changed files with 1622 additions and 1759 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -135,7 +135,9 @@ impl SetupActivity {
error!("Could not leave alternate screen: {}", err); error!("Could not leave alternate screen: {}", err);
} }
// Lock ports // Lock ports
assert!(self.app.lock_ports().is_ok()); if let Err(err) = self.app.lock_ports() {
error!("Failed to lock ports: {err}");
}
// Write key to file // Write key to file
let res = match edit::edit(placeholder.as_bytes()) { let res = match edit::edit(placeholder.as_bytes()) {
Ok(rsa_key) => { Ok(rsa_key) => {
@@ -168,7 +170,9 @@ impl SetupActivity {
error!("Could not clear screen screen: {}", err); error!("Could not clear screen screen: {}", err);
} }
// Unlock ports // Unlock ports
assert!(self.app.unlock_ports().is_ok()); if let Err(err) = self.app.unlock_ports() {
error!("Failed to unlock ports: {err}");
}
} }
res res

View File

@@ -71,7 +71,9 @@ impl SetupActivity {
error!("Could not leave alternate screen: {}", err); error!("Could not leave alternate screen: {}", err);
} }
// Lock ports // Lock ports
assert!(self.app.lock_ports().is_ok()); if let Err(err) = self.app.lock_ports() {
error!("Failed to lock ports: {err}");
}
// Get result // Get result
let result: Result<(), String> = match ctx.config().iter_ssh_keys().nth(idx) { let result: Result<(), String> = match ctx.config().iter_ssh_keys().nth(idx) {
Some(key) => { Some(key) => {
@@ -100,7 +102,9 @@ impl SetupActivity {
error!("Failed to enter raw mode: {}", err); error!("Failed to enter raw mode: {}", err);
} }
// Unlock ports // Unlock ports
assert!(self.app.unlock_ports().is_ok()); if let Err(err) = self.app.unlock_ports() {
error!("Failed to unlock ports: {err}");
}
// Return result // Return result
result result
} }

View File

@@ -103,110 +103,120 @@ impl SetupActivity {
fn config_update(&mut self, msg: ConfigMsg) -> Option<Msg> { fn config_update(&mut self, msg: ConfigMsg) -> Option<Msg> {
match msg { match msg {
ConfigMsg::CheckUpdatesBlurDown => { ConfigMsg::CheckUpdatesBlurDown => {
assert!( if let Err(err) = self.app.active(&Id::Config(IdConfig::PromptOnFileReplace)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Config(IdConfig::PromptOnFileReplace)) }
.is_ok()
);
} }
ConfigMsg::CheckUpdatesBlurUp => { ConfigMsg::CheckUpdatesBlurUp => {
assert!(self.app.active(&Id::Config(IdConfig::HiddenFiles)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::HiddenFiles)) {
error!("Failed to activate component: {err}");
}
} }
ConfigMsg::DefaultProtocolBlurDown => { ConfigMsg::DefaultProtocolBlurDown => {
assert!(self.app.active(&Id::Config(IdConfig::HiddenFiles)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::HiddenFiles)) {
error!("Failed to activate component: {err}");
}
} }
ConfigMsg::DefaultProtocolBlurUp => { ConfigMsg::DefaultProtocolBlurUp => {
assert!(self.app.active(&Id::Config(IdConfig::TextEditor)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::TextEditor)) {
error!("Failed to activate component: {err}");
}
} }
ConfigMsg::GroupDirsBlurDown => { ConfigMsg::GroupDirsBlurDown => {
assert!(self.app.active(&Id::Config(IdConfig::LocalFileFmt)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::LocalFileFmt)) {
error!("Failed to activate component: {err}");
}
} }
ConfigMsg::GroupDirsBlurUp => { ConfigMsg::GroupDirsBlurUp => {
assert!( if let Err(err) = self.app.active(&Id::Config(IdConfig::PromptOnFileReplace)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Config(IdConfig::PromptOnFileReplace)) }
.is_ok()
);
} }
ConfigMsg::HiddenFilesBlurDown => { ConfigMsg::HiddenFilesBlurDown => {
assert!(self.app.active(&Id::Config(IdConfig::CheckUpdates)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::CheckUpdates)) {
error!("Failed to activate component: {err}");
}
} }
ConfigMsg::HiddenFilesBlurUp => { ConfigMsg::HiddenFilesBlurUp => {
assert!( if let Err(err) = self.app.active(&Id::Config(IdConfig::DefaultProtocol)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Config(IdConfig::DefaultProtocol)) }
.is_ok()
);
} }
ConfigMsg::LocalFileFmtBlurDown => { ConfigMsg::LocalFileFmtBlurDown => {
assert!( if let Err(err) = self.app.active(&Id::Config(IdConfig::RemoteFileFmt)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Config(IdConfig::RemoteFileFmt)) }
.is_ok()
);
} }
ConfigMsg::LocalFileFmtBlurUp => { ConfigMsg::LocalFileFmtBlurUp => {
assert!(self.app.active(&Id::Config(IdConfig::GroupDirs)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::GroupDirs)) {
error!("Failed to activate component: {err}");
}
} }
ConfigMsg::NotificationsEnabledBlurDown => { ConfigMsg::NotificationsEnabledBlurDown => {
assert!( if let Err(err) = self
self.app .app
.active(&Id::Config(IdConfig::NotificationsThreshold)) .active(&Id::Config(IdConfig::NotificationsThreshold))
.is_ok() {
); error!("Failed to activate component: {err}");
}
} }
ConfigMsg::NotificationsEnabledBlurUp => { ConfigMsg::NotificationsEnabledBlurUp => {
assert!( if let Err(err) = self.app.active(&Id::Config(IdConfig::RemoteFileFmt)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Config(IdConfig::RemoteFileFmt)) }
.is_ok()
);
} }
ConfigMsg::NotificationsThresholdBlurDown => { ConfigMsg::NotificationsThresholdBlurDown => {
assert!(self.app.active(&Id::Config(IdConfig::SshConfig)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::SshConfig)) {
error!("Failed to activate component: {err}");
}
} }
ConfigMsg::NotificationsThresholdBlurUp => { ConfigMsg::NotificationsThresholdBlurUp => {
assert!( if let Err(err) = self.app.active(&Id::Config(IdConfig::NotificationsEnabled)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Config(IdConfig::NotificationsEnabled)) }
.is_ok()
);
} }
ConfigMsg::PromptOnFileReplaceBlurDown => { ConfigMsg::PromptOnFileReplaceBlurDown => {
assert!(self.app.active(&Id::Config(IdConfig::GroupDirs)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::GroupDirs)) {
error!("Failed to activate component: {err}");
}
} }
ConfigMsg::PromptOnFileReplaceBlurUp => { ConfigMsg::PromptOnFileReplaceBlurUp => {
assert!(self.app.active(&Id::Config(IdConfig::CheckUpdates)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::CheckUpdates)) {
error!("Failed to activate component: {err}");
}
} }
ConfigMsg::RemoteFileFmtBlurDown => { ConfigMsg::RemoteFileFmtBlurDown => {
assert!( if let Err(err) = self.app.active(&Id::Config(IdConfig::NotificationsEnabled)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Config(IdConfig::NotificationsEnabled)) }
.is_ok()
);
} }
ConfigMsg::RemoteFileFmtBlurUp => { ConfigMsg::RemoteFileFmtBlurUp => {
assert!(self.app.active(&Id::Config(IdConfig::LocalFileFmt)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::LocalFileFmt)) {
error!("Failed to activate component: {err}");
}
} }
ConfigMsg::TextEditorBlurDown => { ConfigMsg::TextEditorBlurDown => {
assert!( if let Err(err) = self.app.active(&Id::Config(IdConfig::DefaultProtocol)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Config(IdConfig::DefaultProtocol)) }
.is_ok()
);
} }
ConfigMsg::TextEditorBlurUp => { ConfigMsg::TextEditorBlurUp => {
assert!(self.app.active(&Id::Config(IdConfig::SshConfig)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::SshConfig)) {
error!("Failed to activate component: {err}");
}
} }
ConfigMsg::SshConfigBlurDown => { ConfigMsg::SshConfigBlurDown => {
assert!(self.app.active(&Id::Config(IdConfig::TextEditor)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::TextEditor)) {
error!("Failed to activate component: {err}");
}
} }
ConfigMsg::SshConfigBlurUp => { ConfigMsg::SshConfigBlurUp => {
assert!( if let Err(err) = self
self.app .app
.active(&Id::Config(IdConfig::NotificationsThreshold)) .active(&Id::Config(IdConfig::NotificationsThreshold))
.is_ok() {
); error!("Failed to activate component: {err}");
}
} }
ConfigMsg::ConfigChanged => { ConfigMsg::ConfigChanged => {
self.set_config_changed(true); self.set_config_changed(true);
@@ -251,10 +261,14 @@ impl SetupActivity {
self.mount_new_ssh_key(); self.mount_new_ssh_key();
} }
SshMsg::SshHostBlur => { SshMsg::SshHostBlur => {
assert!(self.app.active(&Id::Ssh(IdSsh::SshUsername)).is_ok()); if let Err(err) = self.app.active(&Id::Ssh(IdSsh::SshUsername)) {
error!("Failed to activate component: {err}");
}
} }
SshMsg::SshUsernameBlur => { SshMsg::SshUsernameBlur => {
assert!(self.app.active(&Id::Ssh(IdSsh::SshHost)).is_ok()); if let Err(err) = self.app.active(&Id::Ssh(IdSsh::SshHost)) {
error!("Failed to activate component: {err}");
}
} }
} }
None None
@@ -263,222 +277,274 @@ impl SetupActivity {
fn theme_update(&mut self, msg: ThemeMsg) -> Option<Msg> { fn theme_update(&mut self, msg: ThemeMsg) -> Option<Msg> {
match msg { match msg {
ThemeMsg::AuthAddressBlurDown => { ThemeMsg::AuthAddressBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::AuthPort)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthPort)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::AuthAddressBlurUp => { ThemeMsg::AuthAddressBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::AuthProtocol)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthProtocol)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::AuthBookmarksBlurDown => { ThemeMsg::AuthBookmarksBlurDown => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthRecentHosts)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::AuthRecentHosts)) }
.is_ok()
);
} }
ThemeMsg::AuthBookmarksBlurUp => { ThemeMsg::AuthBookmarksBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::AuthPassword)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthPassword)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::AuthPasswordBlurDown => { ThemeMsg::AuthPasswordBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::AuthBookmarks)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthBookmarks)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::AuthPasswordBlurUp => { ThemeMsg::AuthPasswordBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::AuthUsername)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthUsername)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::AuthPortBlurDown => { ThemeMsg::AuthPortBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::AuthUsername)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthUsername)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::AuthPortBlurUp => { ThemeMsg::AuthPortBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::AuthAddress)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthAddress)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::AuthProtocolBlurDown => { ThemeMsg::AuthProtocolBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::AuthAddress)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthAddress)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::AuthProtocolBlurUp => { ThemeMsg::AuthProtocolBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::StatusSync)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::StatusSync)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::AuthRecentHostsBlurDown => { ThemeMsg::AuthRecentHostsBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscError)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscError)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::AuthRecentHostsBlurUp => { ThemeMsg::AuthRecentHostsBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::AuthBookmarks)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthBookmarks)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::AuthUsernameBlurDown => { ThemeMsg::AuthUsernameBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::AuthPassword)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthPassword)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::AuthUsernameBlurUp => { ThemeMsg::AuthUsernameBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::AuthPort)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthPort)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::MiscErrorBlurDown => { ThemeMsg::MiscErrorBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscInfo)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscInfo)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::MiscErrorBlurUp => { ThemeMsg::MiscErrorBlurUp => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthRecentHosts)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::AuthRecentHosts)) }
.is_ok()
);
} }
ThemeMsg::MiscInfoBlurDown => { ThemeMsg::MiscInfoBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscInput)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscInput)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::MiscInfoBlurUp => { ThemeMsg::MiscInfoBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscError)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscError)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::MiscInputBlurDown => { ThemeMsg::MiscInputBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscKeys)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscKeys)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::MiscInputBlurUp => { ThemeMsg::MiscInputBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscInfo)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscInfo)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::MiscKeysBlurDown => { ThemeMsg::MiscKeysBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscQuit)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscQuit)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::MiscKeysBlurUp => { ThemeMsg::MiscKeysBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscInput)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscInput)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::MiscQuitBlurDown => { ThemeMsg::MiscQuitBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscSave)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscSave)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::MiscQuitBlurUp => { ThemeMsg::MiscQuitBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscKeys)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscKeys)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::MiscSaveBlurDown => { ThemeMsg::MiscSaveBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscWarn)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscWarn)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::MiscSaveBlurUp => { ThemeMsg::MiscSaveBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscQuit)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscQuit)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::MiscWarnBlurDown => { ThemeMsg::MiscWarnBlurDown => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerLocalBg)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::ExplorerLocalBg)) }
.is_ok()
);
} }
ThemeMsg::MiscWarnBlurUp => { ThemeMsg::MiscWarnBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscSave)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscSave)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::ExplorerLocalBgBlurDown => { ThemeMsg::ExplorerLocalBgBlurDown => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerLocalFg)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::ExplorerLocalFg)) }
.is_ok()
);
} }
ThemeMsg::ExplorerLocalBgBlurUp => { ThemeMsg::ExplorerLocalBgBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::MiscWarn)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::MiscWarn)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::ExplorerLocalFgBlurDown => { ThemeMsg::ExplorerLocalFgBlurDown => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerLocalHg)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::ExplorerLocalHg)) }
.is_ok()
);
} }
ThemeMsg::ExplorerLocalFgBlurUp => { ThemeMsg::ExplorerLocalFgBlurUp => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerLocalBg)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::ExplorerLocalBg)) }
.is_ok()
);
} }
ThemeMsg::ExplorerLocalHgBlurDown => { ThemeMsg::ExplorerLocalHgBlurDown => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerRemoteBg)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::ExplorerRemoteBg)) }
.is_ok()
);
} }
ThemeMsg::ExplorerLocalHgBlurUp => { ThemeMsg::ExplorerLocalHgBlurUp => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerLocalFg)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::ExplorerLocalFg)) }
.is_ok()
);
} }
ThemeMsg::ExplorerRemoteBgBlurDown => { ThemeMsg::ExplorerRemoteBgBlurDown => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerRemoteFg)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::ExplorerRemoteFg)) }
.is_ok()
);
} }
ThemeMsg::ExplorerRemoteBgBlurUp => { ThemeMsg::ExplorerRemoteBgBlurUp => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerLocalHg)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::ExplorerLocalHg)) }
.is_ok()
);
} }
ThemeMsg::ExplorerRemoteFgBlurDown => { ThemeMsg::ExplorerRemoteFgBlurDown => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerRemoteHg)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::ExplorerRemoteHg)) }
.is_ok()
);
} }
ThemeMsg::ExplorerRemoteFgBlurUp => { ThemeMsg::ExplorerRemoteFgBlurUp => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerRemoteBg)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::ExplorerRemoteBg)) }
.is_ok()
);
} }
ThemeMsg::ExplorerRemoteHgBlurDown => { ThemeMsg::ExplorerRemoteHgBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::ProgBarFull)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::ProgBarFull)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::ExplorerRemoteHgBlurUp => { ThemeMsg::ExplorerRemoteHgBlurUp => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerRemoteFg)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::ExplorerRemoteFg)) }
.is_ok()
);
} }
ThemeMsg::ProgBarFullBlurDown => { ThemeMsg::ProgBarFullBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::ProgBarPartial)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::ProgBarPartial)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::ProgBarFullBlurUp => { ThemeMsg::ProgBarFullBlurUp => {
assert!( if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerRemoteHg)) {
self.app error!("Failed to activate component: {err}");
.active(&Id::Theme(IdTheme::ExplorerRemoteHg)) }
.is_ok()
);
} }
ThemeMsg::ProgBarPartialBlurDown => { ThemeMsg::ProgBarPartialBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::LogBg)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::LogBg)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::ProgBarPartialBlurUp => { ThemeMsg::ProgBarPartialBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::ProgBarFull)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::ProgBarFull)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::LogBgBlurDown => { ThemeMsg::LogBgBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::LogWindow)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::LogWindow)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::LogBgBlurUp => { ThemeMsg::LogBgBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::ProgBarPartial)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::ProgBarPartial)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::LogWindowBlurDown => { ThemeMsg::LogWindowBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::StatusSorting)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::StatusSorting)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::LogWindowBlurUp => { ThemeMsg::LogWindowBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::LogBg)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::LogBg)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::StatusSortingBlurDown => { ThemeMsg::StatusSortingBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::StatusHidden)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::StatusHidden)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::StatusSortingBlurUp => { ThemeMsg::StatusSortingBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::LogWindow)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::LogWindow)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::StatusHiddenBlurDown => { ThemeMsg::StatusHiddenBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::StatusSync)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::StatusSync)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::StatusHiddenBlurUp => { ThemeMsg::StatusHiddenBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::StatusSorting)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::StatusSorting)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::StatusSyncBlurDown => { ThemeMsg::StatusSyncBlurDown => {
assert!(self.app.active(&Id::Theme(IdTheme::AuthProtocol)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthProtocol)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::StatusSyncBlurUp => { ThemeMsg::StatusSyncBlurUp => {
assert!(self.app.active(&Id::Theme(IdTheme::StatusHidden)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::StatusHidden)) {
error!("Failed to activate component: {err}");
}
} }
ThemeMsg::ColorChanged(id, color) => { ThemeMsg::ColorChanged(id, color) => {
self.action_save_color(id, color); self.action_save_color(id, color);

View File

@@ -40,16 +40,16 @@ impl SetupActivity {
/// Mount error box /// Mount error box
pub(super) fn mount_error<S: AsRef<str>>(&mut self, text: S) { pub(super) fn mount_error<S: AsRef<str>>(&mut self, text: S) {
assert!( if let Err(err) = self.app.remount(
self.app Id::Common(IdCommon::ErrorPopup),
.remount( Box::new(components::ErrorPopup::new(text)),
Id::Common(IdCommon::ErrorPopup), vec![],
Box::new(components::ErrorPopup::new(text)), ) {
vec![], error!("Failed to remount component: {err}");
) }
.is_ok() if let Err(err) = self.app.active(&Id::Common(IdCommon::ErrorPopup)) {
); error!("Failed to activate component: {err}");
assert!(self.app.active(&Id::Common(IdCommon::ErrorPopup)).is_ok()); }
} }
/// Umount error message /// Umount error message
@@ -59,16 +59,16 @@ impl SetupActivity {
/// Mount quit popup /// Mount quit popup
pub(super) fn mount_quit(&mut self) { pub(super) fn mount_quit(&mut self) {
assert!( if let Err(err) = self.app.remount(
self.app Id::Common(IdCommon::QuitPopup),
.remount( Box::<components::QuitPopup>::default(),
Id::Common(IdCommon::QuitPopup), vec![],
Box::<components::QuitPopup>::default(), ) {
vec![], error!("Failed to remount component: {err}");
) }
.is_ok() if let Err(err) = self.app.active(&Id::Common(IdCommon::QuitPopup)) {
); error!("Failed to activate component: {err}");
assert!(self.app.active(&Id::Common(IdCommon::QuitPopup)).is_ok()); }
} }
/// Umount quit /// Umount quit
@@ -78,16 +78,16 @@ impl SetupActivity {
/// Mount save popup /// Mount save popup
pub(super) fn mount_save_popup(&mut self) { pub(super) fn mount_save_popup(&mut self) {
assert!( if let Err(err) = self.app.remount(
self.app Id::Common(IdCommon::SavePopup),
.remount( Box::<components::SavePopup>::default(),
Id::Common(IdCommon::SavePopup), vec![],
Box::<components::SavePopup>::default(), ) {
vec![], error!("Failed to remount component: {err}");
) }
.is_ok() if let Err(err) = self.app.active(&Id::Common(IdCommon::SavePopup)) {
); error!("Failed to activate component: {err}");
assert!(self.app.active(&Id::Common(IdCommon::SavePopup)).is_ok()); }
} }
/// Umount quit /// Umount quit
@@ -97,16 +97,16 @@ impl SetupActivity {
/// Mount help /// Mount help
pub(super) fn mount_help(&mut self) { pub(super) fn mount_help(&mut self) {
assert!( if let Err(err) = self.app.remount(
self.app Id::Common(IdCommon::Keybindings),
.remount( Box::<components::Keybindings>::default(),
Id::Common(IdCommon::Keybindings), vec![],
Box::<components::Keybindings>::default(), ) {
vec![], error!("Failed to remount component: {err}");
) }
.is_ok() if let Err(err) = self.app.active(&Id::Common(IdCommon::Keybindings)) {
); error!("Failed to activate component: {err}");
assert!(self.app.active(&Id::Common(IdCommon::Keybindings)).is_ok()); }
} }
/// Umount help /// Umount help
@@ -148,96 +148,90 @@ impl SetupActivity {
/// Mount common components /// Mount common components
fn mount_commons(&mut self, layout: ViewLayout) { fn mount_commons(&mut self, layout: ViewLayout) {
// Radio tab // Radio tab
assert!( if let Err(err) = self.app.remount(
self.app Id::Common(IdCommon::Header),
.remount( Box::new(components::Header::new(layout)),
Id::Common(IdCommon::Header), vec![],
Box::new(components::Header::new(layout)), ) {
vec![], error!("Failed to remount component: {err}");
) }
.is_ok()
);
// Footer // Footer
assert!( if let Err(err) = self.app.remount(
self.app Id::Common(IdCommon::Footer),
.remount( Box::<components::Footer>::default(),
Id::Common(IdCommon::Footer), vec![],
Box::<components::Footer>::default(), ) {
vec![], error!("Failed to remount component: {err}");
) }
.is_ok()
);
} }
/// Mount global listener /// Mount global listener
fn mount_global_listener(&mut self) { fn mount_global_listener(&mut self) {
assert!( if let Err(err) = self.app.mount(
self.app Id::Common(IdCommon::GlobalListener),
.mount( Box::<components::GlobalListener>::default(),
Id::Common(IdCommon::GlobalListener), vec![
Box::<components::GlobalListener>::default(), Sub::new(
vec![ SubEventClause::Keyboard(KeyEvent {
Sub::new( code: Key::Esc,
SubEventClause::Keyboard(KeyEvent { modifiers: KeyModifiers::NONE,
code: Key::Esc, }),
modifiers: KeyModifiers::NONE, Self::no_popup_mounted_clause(),
}), ),
Self::no_popup_mounted_clause(), Sub::new(
), SubEventClause::Keyboard(KeyEvent {
Sub::new( code: Key::Function(10),
SubEventClause::Keyboard(KeyEvent { modifiers: KeyModifiers::NONE,
code: Key::Function(10), }),
modifiers: KeyModifiers::NONE, Self::no_popup_mounted_clause(),
}), ),
Self::no_popup_mounted_clause(), Sub::new(
), SubEventClause::Keyboard(KeyEvent {
Sub::new( code: Key::Tab,
SubEventClause::Keyboard(KeyEvent { modifiers: KeyModifiers::NONE,
code: Key::Tab, }),
modifiers: KeyModifiers::NONE, Self::no_popup_mounted_clause(),
}), ),
Self::no_popup_mounted_clause(), Sub::new(
), SubEventClause::Keyboard(KeyEvent {
Sub::new( code: Key::Char('h'),
SubEventClause::Keyboard(KeyEvent { modifiers: KeyModifiers::CONTROL,
code: Key::Char('h'), }),
modifiers: KeyModifiers::CONTROL, Self::no_popup_mounted_clause(),
}), ),
Self::no_popup_mounted_clause(), Sub::new(
), SubEventClause::Keyboard(KeyEvent {
Sub::new( code: Key::Function(1),
SubEventClause::Keyboard(KeyEvent { modifiers: KeyModifiers::NONE,
code: Key::Function(1), }),
modifiers: KeyModifiers::NONE, Self::no_popup_mounted_clause(),
}), ),
Self::no_popup_mounted_clause(), Sub::new(
), SubEventClause::Keyboard(KeyEvent {
Sub::new( code: Key::Char('r'),
SubEventClause::Keyboard(KeyEvent { modifiers: KeyModifiers::CONTROL,
code: Key::Char('r'), }),
modifiers: KeyModifiers::CONTROL, Self::no_popup_mounted_clause(),
}), ),
Self::no_popup_mounted_clause(), Sub::new(
), SubEventClause::Keyboard(KeyEvent {
Sub::new( code: Key::Char('s'),
SubEventClause::Keyboard(KeyEvent { modifiers: KeyModifiers::CONTROL,
code: Key::Char('s'), }),
modifiers: KeyModifiers::CONTROL, Self::no_popup_mounted_clause(),
}), ),
Self::no_popup_mounted_clause(), Sub::new(
), SubEventClause::Keyboard(KeyEvent {
Sub::new( code: Key::Function(4),
SubEventClause::Keyboard(KeyEvent { modifiers: KeyModifiers::NONE,
code: Key::Function(4), }),
modifiers: KeyModifiers::NONE, Self::no_popup_mounted_clause(),
}), ),
Self::no_popup_mounted_clause(), Sub::new(SubEventClause::WindowResize, SubClause::Always),
), ],
Sub::new(SubEventClause::WindowResize, SubClause::Always) ) {
] error!("Failed to mount component: {err}");
) }
.is_ok()
);
} }
/// Returns a sub clause which requires that no popup is mounted in order to be satisfied /// Returns a sub clause which requires that no popup is mounted in order to be satisfied

View File

@@ -32,7 +32,9 @@ impl SetupActivity {
// Load values // Load values
self.load_input_values(); self.load_input_values();
// Active text editor // Active text editor
assert!(self.app.active(&Id::Config(IdConfig::TextEditor)).is_ok()); if let Err(err) = self.app.active(&Id::Config(IdConfig::TextEditor)) {
error!("Failed to activate component: {err}");
}
} }
pub(super) fn view_setup(&mut self) { pub(super) fn view_setup(&mut self) {
@@ -145,133 +147,111 @@ impl SetupActivity {
// Text editor // Text editor
let text_editor: String = let text_editor: String =
String::from(self.config().get_text_editor().as_path().to_string_lossy()); String::from(self.config().get_text_editor().as_path().to_string_lossy());
assert!( if let Err(err) = self.app.remount(
self.app Id::Config(IdConfig::TextEditor),
.remount( Box::new(components::TextEditor::new(text_editor.as_str())),
Id::Config(IdConfig::TextEditor), vec![],
Box::new(components::TextEditor::new(text_editor.as_str())), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok()
);
// Protocol // Protocol
assert!( if let Err(err) = self.app.remount(
self.app Id::Config(IdConfig::DefaultProtocol),
.remount( Box::new(components::DefaultProtocol::new(
Id::Config(IdConfig::DefaultProtocol), self.config().get_default_protocol(),
Box::new(components::DefaultProtocol::new( )),
self.config().get_default_protocol() vec![],
)), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok()
);
// Hidden files // Hidden files
assert!( if let Err(err) = self.app.remount(
self.app Id::Config(IdConfig::HiddenFiles),
.remount( Box::new(components::HiddenFiles::new(
Id::Config(IdConfig::HiddenFiles), self.config().get_show_hidden_files(),
Box::new(components::HiddenFiles::new( )),
self.config().get_show_hidden_files() vec![],
)), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok()
);
// Updates // Updates
assert!( if let Err(err) = self.app.remount(
self.app Id::Config(IdConfig::CheckUpdates),
.remount( Box::new(components::CheckUpdates::new(
Id::Config(IdConfig::CheckUpdates), self.config().get_check_for_updates(),
Box::new(components::CheckUpdates::new( )),
self.config().get_check_for_updates() vec![],
)), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok()
);
// File replace // File replace
assert!( if let Err(err) = self.app.remount(
self.app Id::Config(IdConfig::PromptOnFileReplace),
.remount( Box::new(components::PromptOnFileReplace::new(
Id::Config(IdConfig::PromptOnFileReplace), self.config().get_prompt_on_file_replace(),
Box::new(components::PromptOnFileReplace::new( )),
self.config().get_prompt_on_file_replace() vec![],
)), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok()
);
// Group dirs // Group dirs
assert!( if let Err(err) = self.app.remount(
self.app Id::Config(IdConfig::GroupDirs),
.remount( Box::new(components::GroupDirs::new(self.config().get_group_dirs())),
Id::Config(IdConfig::GroupDirs), vec![],
Box::new(components::GroupDirs::new(self.config().get_group_dirs())), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok()
);
// Local File Fmt // Local File Fmt
assert!( if let Err(err) = self.app.remount(
self.app Id::Config(IdConfig::LocalFileFmt),
.remount( Box::new(components::LocalFileFmt::new(
Id::Config(IdConfig::LocalFileFmt), &self.config().get_local_file_fmt().unwrap_or_default(),
Box::new(components::LocalFileFmt::new( )),
&self.config().get_local_file_fmt().unwrap_or_default() vec![],
)), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok()
);
// Remote File Fmt // Remote File Fmt
assert!( if let Err(err) = self.app.remount(
self.app Id::Config(IdConfig::RemoteFileFmt),
.remount( Box::new(components::RemoteFileFmt::new(
Id::Config(IdConfig::RemoteFileFmt), &self.config().get_remote_file_fmt().unwrap_or_default(),
Box::new(components::RemoteFileFmt::new( )),
&self.config().get_remote_file_fmt().unwrap_or_default() vec![],
)), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok()
);
// Notifications enabled // Notifications enabled
assert!( if let Err(err) = self.app.remount(
self.app Id::Config(IdConfig::NotificationsEnabled),
.remount( Box::new(components::NotificationsEnabled::new(
Id::Config(IdConfig::NotificationsEnabled), self.config().get_notifications(),
Box::new(components::NotificationsEnabled::new( )),
self.config().get_notifications() vec![],
)), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok()
);
// Notifications threshold // Notifications threshold
assert!( if let Err(err) = self.app.remount(
self.app Id::Config(IdConfig::NotificationsThreshold),
.remount( Box::new(components::NotificationsThreshold::new(&fmt_bytes(
Id::Config(IdConfig::NotificationsThreshold), self.config().get_notification_threshold(),
Box::new(components::NotificationsThreshold::new(&fmt_bytes( ))),
self.config().get_notification_threshold() vec![],
))), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok()
);
// Ssh config // Ssh config
assert!( if let Err(err) = self.app.remount(
self.app Id::Config(IdConfig::SshConfig),
.remount( Box::new(components::SshConfig::new(
Id::Config(IdConfig::SshConfig), self.config().get_ssh_config().unwrap_or(""),
Box::new(components::SshConfig::new( )),
self.config().get_ssh_config().unwrap_or("") vec![],
)), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok()
);
} }
/// Collect values from input and put them into the configuration /// Collect values from input and put them into the configuration

View File

@@ -74,16 +74,16 @@ impl SetupActivity {
/// Mount delete ssh key component /// Mount delete ssh key component
pub(crate) fn mount_del_ssh_key(&mut self) { pub(crate) fn mount_del_ssh_key(&mut self) {
assert!( if let Err(err) = self.app.remount(
self.app Id::Ssh(IdSsh::DelSshKeyPopup),
.remount( Box::<components::DelSshKeyPopup>::default(),
Id::Ssh(IdSsh::DelSshKeyPopup), vec![],
Box::<components::DelSshKeyPopup>::default(), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok() if let Err(err) = self.app.active(&Id::Ssh(IdSsh::DelSshKeyPopup)) {
); error!("Failed to activate component: {err}");
assert!(self.app.active(&Id::Ssh(IdSsh::DelSshKeyPopup)).is_ok()); }
} }
/// Umount delete ssh key /// Umount delete ssh key
@@ -93,25 +93,23 @@ impl SetupActivity {
/// Mount new ssh key prompt /// Mount new ssh key prompt
pub(crate) fn mount_new_ssh_key(&mut self) { pub(crate) fn mount_new_ssh_key(&mut self) {
assert!( if let Err(err) = self.app.remount(
self.app Id::Ssh(IdSsh::SshHost),
.remount( Box::<components::SshHost>::default(),
Id::Ssh(IdSsh::SshHost), vec![],
Box::<components::SshHost>::default(), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok() if let Err(err) = self.app.remount(
); Id::Ssh(IdSsh::SshUsername),
assert!( Box::<components::SshUsername>::default(),
self.app vec![],
.remount( ) {
Id::Ssh(IdSsh::SshUsername), error!("Failed to remount component: {err}");
Box::<components::SshUsername>::default(), }
vec![] if let Err(err) = self.app.active(&Id::Ssh(IdSsh::SshHost)) {
) error!("Failed to activate component: {err}");
.is_ok() }
);
assert!(self.app.active(&Id::Ssh(IdSsh::SshHost)).is_ok());
} }
/// Umount new ssh key prompt /// Umount new ssh key prompt
@@ -130,15 +128,15 @@ impl SetupActivity {
format!("{username} at {addr}") format!("{username} at {addr}")
}) })
.collect(); .collect();
assert!( if let Err(err) = self.app.remount(
self.app Id::Ssh(IdSsh::SshKeys),
.remount( Box::new(components::SshKeys::new(&keys)),
Id::Ssh(IdSsh::SshKeys), vec![],
Box::new(components::SshKeys::new(&keys)), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok() if let Err(err) = self.app.active(&Id::Ssh(IdSsh::SshKeys)) {
); error!("Failed to activate component: {err}");
assert!(self.app.active(&Id::Ssh(IdSsh::SshKeys)).is_ok()); }
} }
} }

View File

@@ -21,7 +21,9 @@ impl SetupActivity {
// Load styles // Load styles
self.load_styles(); self.load_styles();
// Active first field // Active first field
assert!(self.app.active(&Id::Theme(IdTheme::AuthProtocol)).is_ok()); if let Err(err) = self.app.active(&Id::Theme(IdTheme::AuthProtocol)) {
error!("Failed to activate component: {err}");
}
} }
pub(super) fn view_theme(&mut self) { pub(super) fn view_theme(&mut self) {
@@ -242,309 +244,247 @@ impl SetupActivity {
} }
fn load_titles(&mut self) { fn load_titles(&mut self) {
assert!( if let Err(err) = self.app.remount(
self.app Id::Theme(IdTheme::AuthTitle),
.remount( Box::<components::AuthTitle>::default(),
Id::Theme(IdTheme::AuthTitle), vec![],
Box::<components::AuthTitle>::default(), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok() if let Err(err) = self.app.remount(
); Id::Theme(IdTheme::MiscTitle),
assert!( Box::<components::MiscTitle>::default(),
self.app vec![],
.remount( ) {
Id::Theme(IdTheme::MiscTitle), error!("Failed to remount component: {err}");
Box::<components::MiscTitle>::default(), }
vec![] if let Err(err) = self.app.remount(
) Id::Theme(IdTheme::TransferTitle),
.is_ok() Box::<components::TransferTitle>::default(),
); vec![],
assert!( ) {
self.app error!("Failed to remount component: {err}");
.remount( }
Id::Theme(IdTheme::TransferTitle), if let Err(err) = self.app.remount(
Box::<components::TransferTitle>::default(), Id::Theme(IdTheme::TransferTitle2),
vec![] Box::<components::TransferTitle2>::default(),
) vec![],
.is_ok() ) {
); error!("Failed to remount component: {err}");
assert!( }
self.app
.remount(
Id::Theme(IdTheme::TransferTitle2),
Box::<components::TransferTitle2>::default(),
vec![]
)
.is_ok()
);
} }
/// Load values from theme into input fields /// Load values from theme into input fields
pub(crate) fn load_styles(&mut self) { pub(crate) fn load_styles(&mut self) {
let theme: Theme = self.theme().clone(); let theme: Theme = self.theme().clone();
assert!( if let Err(err) = self.app.remount(
self.app Id::Theme(IdTheme::AuthAddress),
.remount( Box::new(components::AuthAddress::new(theme.auth_address)),
Id::Theme(IdTheme::AuthAddress), vec![],
Box::new(components::AuthAddress::new(theme.auth_address)), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok() if let Err(err) = self.app.remount(
); Id::Theme(IdTheme::AuthBookmarks),
assert!( Box::new(components::AuthBookmarks::new(theme.auth_bookmarks)),
self.app vec![],
.remount( ) {
Id::Theme(IdTheme::AuthBookmarks), error!("Failed to remount component: {err}");
Box::new(components::AuthBookmarks::new(theme.auth_bookmarks)), }
vec![] if let Err(err) = self.app.remount(
) Id::Theme(IdTheme::AuthPassword),
.is_ok() Box::new(components::AuthPassword::new(theme.auth_password)),
); vec![],
assert!( ) {
self.app error!("Failed to remount component: {err}");
.remount( }
Id::Theme(IdTheme::AuthPassword), if let Err(err) = self.app.remount(
Box::new(components::AuthPassword::new(theme.auth_password)), Id::Theme(IdTheme::AuthPort),
vec![] Box::new(components::AuthPort::new(theme.auth_port)),
) vec![],
.is_ok() ) {
); error!("Failed to remount component: {err}");
assert!( }
self.app if let Err(err) = self.app.remount(
.remount( Id::Theme(IdTheme::AuthProtocol),
Id::Theme(IdTheme::AuthPort), Box::new(components::AuthProtocol::new(theme.auth_protocol)),
Box::new(components::AuthPort::new(theme.auth_port)), vec![],
vec![] ) {
) error!("Failed to remount component: {err}");
.is_ok() }
); if let Err(err) = self.app.remount(
assert!( Id::Theme(IdTheme::AuthRecentHosts),
self.app Box::new(components::AuthRecentHosts::new(theme.auth_recents)),
.remount( vec![],
Id::Theme(IdTheme::AuthProtocol), ) {
Box::new(components::AuthProtocol::new(theme.auth_protocol)), error!("Failed to remount component: {err}");
vec![] }
) if let Err(err) = self.app.remount(
.is_ok() Id::Theme(IdTheme::AuthUsername),
); Box::new(components::AuthUsername::new(theme.auth_username)),
assert!( vec![],
self.app ) {
.remount( error!("Failed to remount component: {err}");
Id::Theme(IdTheme::AuthRecentHosts), }
Box::new(components::AuthRecentHosts::new(theme.auth_recents)), if let Err(err) = self.app.remount(
vec![] Id::Theme(IdTheme::MiscError),
) Box::new(components::MiscError::new(theme.misc_error_dialog)),
.is_ok() vec![],
); ) {
assert!( error!("Failed to remount component: {err}");
self.app }
.remount( if let Err(err) = self.app.remount(
Id::Theme(IdTheme::AuthUsername), Id::Theme(IdTheme::MiscInfo),
Box::new(components::AuthUsername::new(theme.auth_username)), Box::new(components::MiscInfo::new(theme.misc_info_dialog)),
vec![] vec![],
) ) {
.is_ok() error!("Failed to remount component: {err}");
); }
assert!( if let Err(err) = self.app.remount(
self.app Id::Theme(IdTheme::MiscInput),
.remount( Box::new(components::MiscInput::new(theme.misc_input_dialog)),
Id::Theme(IdTheme::MiscError), vec![],
Box::new(components::MiscError::new(theme.misc_error_dialog)), ) {
vec![] error!("Failed to remount component: {err}");
) }
.is_ok() if let Err(err) = self.app.remount(
); Id::Theme(IdTheme::MiscKeys),
assert!( Box::new(components::MiscKeys::new(theme.misc_keys)),
self.app vec![],
.remount( ) {
Id::Theme(IdTheme::MiscInfo), error!("Failed to remount component: {err}");
Box::new(components::MiscInfo::new(theme.misc_info_dialog)), }
vec![] if let Err(err) = self.app.remount(
) Id::Theme(IdTheme::MiscQuit),
.is_ok() Box::new(components::MiscQuit::new(theme.misc_quit_dialog)),
); vec![],
assert!( ) {
self.app error!("Failed to remount component: {err}");
.remount( }
Id::Theme(IdTheme::MiscInput), if let Err(err) = self.app.remount(
Box::new(components::MiscInput::new(theme.misc_input_dialog)), Id::Theme(IdTheme::MiscSave),
vec![] Box::new(components::MiscSave::new(theme.misc_save_dialog)),
) vec![],
.is_ok() ) {
); error!("Failed to remount component: {err}");
assert!( }
self.app if let Err(err) = self.app.remount(
.remount( Id::Theme(IdTheme::MiscWarn),
Id::Theme(IdTheme::MiscKeys), Box::new(components::MiscWarn::new(theme.misc_warn_dialog)),
Box::new(components::MiscKeys::new(theme.misc_keys)), vec![],
vec![] ) {
) error!("Failed to remount component: {err}");
.is_ok() }
); if let Err(err) = self.app.remount(
assert!( Id::Theme(IdTheme::ExplorerLocalBg),
self.app Box::new(components::ExplorerLocalBg::new(
.remount( theme.transfer_local_explorer_background,
Id::Theme(IdTheme::MiscQuit), )),
Box::new(components::MiscQuit::new(theme.misc_quit_dialog)), vec![],
vec![] ) {
) error!("Failed to remount component: {err}");
.is_ok() }
); if let Err(err) = self.app.remount(
assert!( Id::Theme(IdTheme::ExplorerLocalFg),
self.app Box::new(components::ExplorerLocalFg::new(
.remount( theme.transfer_local_explorer_foreground,
Id::Theme(IdTheme::MiscSave), )),
Box::new(components::MiscSave::new(theme.misc_save_dialog)), vec![],
vec![] ) {
) error!("Failed to remount component: {err}");
.is_ok() }
); if let Err(err) = self.app.remount(
assert!( Id::Theme(IdTheme::ExplorerLocalHg),
self.app Box::new(components::ExplorerLocalHg::new(
.remount( theme.transfer_local_explorer_highlighted,
Id::Theme(IdTheme::MiscWarn), )),
Box::new(components::MiscWarn::new(theme.misc_warn_dialog)), vec![],
vec![] ) {
) error!("Failed to remount component: {err}");
.is_ok() }
); if let Err(err) = self.app.remount(
assert!( Id::Theme(IdTheme::ExplorerRemoteBg),
self.app Box::new(components::ExplorerRemoteBg::new(
.remount( theme.transfer_remote_explorer_background,
Id::Theme(IdTheme::ExplorerLocalBg), )),
Box::new(components::ExplorerLocalBg::new( vec![],
theme.transfer_local_explorer_background ) {
)), error!("Failed to remount component: {err}");
vec![] }
) if let Err(err) = self.app.remount(
.is_ok() Id::Theme(IdTheme::ExplorerRemoteFg),
); Box::new(components::ExplorerRemoteFg::new(
assert!( theme.transfer_remote_explorer_foreground,
self.app )),
.remount( vec![],
Id::Theme(IdTheme::ExplorerLocalFg), ) {
Box::new(components::ExplorerLocalFg::new( error!("Failed to remount component: {err}");
theme.transfer_local_explorer_foreground }
)), if let Err(err) = self.app.remount(
vec![] Id::Theme(IdTheme::ExplorerRemoteHg),
) Box::new(components::ExplorerRemoteHg::new(
.is_ok() theme.transfer_remote_explorer_highlighted,
); )),
assert!( vec![],
self.app ) {
.remount( error!("Failed to remount component: {err}");
Id::Theme(IdTheme::ExplorerLocalHg), }
Box::new(components::ExplorerLocalHg::new( if let Err(err) = self.app.remount(
theme.transfer_local_explorer_highlighted Id::Theme(IdTheme::ProgBarFull),
)), Box::new(components::ProgBarFull::new(
vec![] theme.transfer_progress_bar_full,
) )),
.is_ok() vec![],
); ) {
assert!( error!("Failed to remount component: {err}");
self.app }
.remount( if let Err(err) = self.app.remount(
Id::Theme(IdTheme::ExplorerRemoteBg), Id::Theme(IdTheme::ProgBarPartial),
Box::new(components::ExplorerRemoteBg::new( Box::new(components::ProgBarPartial::new(
theme.transfer_remote_explorer_background theme.transfer_progress_bar_partial,
)), )),
vec![] vec![],
) ) {
.is_ok() error!("Failed to remount component: {err}");
); }
assert!( if let Err(err) = self.app.remount(
self.app Id::Theme(IdTheme::LogBg),
.remount( Box::new(components::LogBg::new(theme.transfer_log_background)),
Id::Theme(IdTheme::ExplorerRemoteFg), vec![],
Box::new(components::ExplorerRemoteFg::new( ) {
theme.transfer_remote_explorer_foreground error!("Failed to remount component: {err}");
)), }
vec![] if let Err(err) = self.app.remount(
) Id::Theme(IdTheme::LogWindow),
.is_ok() Box::new(components::LogWindow::new(theme.transfer_log_window)),
); vec![],
assert!( ) {
self.app error!("Failed to remount component: {err}");
.remount( }
Id::Theme(IdTheme::ExplorerRemoteHg), if let Err(err) = self.app.remount(
Box::new(components::ExplorerRemoteHg::new( Id::Theme(IdTheme::StatusSorting),
theme.transfer_remote_explorer_highlighted Box::new(components::StatusSorting::new(
)), theme.transfer_status_sorting,
vec![] )),
) vec![],
.is_ok() ) {
); error!("Failed to remount component: {err}");
assert!( }
self.app if let Err(err) = self.app.remount(
.remount( Id::Theme(IdTheme::StatusHidden),
Id::Theme(IdTheme::ProgBarFull), Box::new(components::StatusHidden::new(theme.transfer_status_hidden)),
Box::new(components::ProgBarFull::new( vec![],
theme.transfer_progress_bar_full ) {
)), error!("Failed to remount component: {err}");
vec![] }
) if let Err(err) = self.app.remount(
.is_ok() Id::Theme(IdTheme::StatusSync),
); Box::new(components::StatusSync::new(
assert!( theme.transfer_status_sync_browsing,
self.app )),
.remount( vec![],
Id::Theme(IdTheme::ProgBarPartial), ) {
Box::new(components::ProgBarPartial::new( error!("Failed to remount component: {err}");
theme.transfer_progress_bar_partial }
)),
vec![]
)
.is_ok()
);
assert!(
self.app
.remount(
Id::Theme(IdTheme::LogBg),
Box::new(components::LogBg::new(theme.transfer_log_background)),
vec![]
)
.is_ok()
);
assert!(
self.app
.remount(
Id::Theme(IdTheme::LogWindow),
Box::new(components::LogWindow::new(theme.transfer_log_window)),
vec![]
)
.is_ok()
);
assert!(
self.app
.remount(
Id::Theme(IdTheme::StatusSorting),
Box::new(components::StatusSorting::new(
theme.transfer_status_sorting
)),
vec![]
)
.is_ok()
);
assert!(
self.app
.remount(
Id::Theme(IdTheme::StatusHidden),
Box::new(components::StatusHidden::new(theme.transfer_status_hidden)),
vec![]
)
.is_ok()
);
assert!(
self.app
.remount(
Id::Theme(IdTheme::StatusSync),
Box::new(components::StatusSync::new(
theme.transfer_status_sync_browsing
)),
vec![]
)
.is_ok()
);
} }
} }