feat: implement on_app_start to set default exchange rate adapter in settings
All checks were successful
Lint / lint-frontend (pull_request) Successful in 20s
Test / test-crates (pull_request) Successful in 1m29s
Lint / lint-crates (pull_request) Successful in 1m55s

This commit is contained in:
2026-02-21 02:09:52 +00:00
parent f526d9ab2b
commit a0d5bae160

View File

@@ -138,7 +138,31 @@ impl ExchangeRateServiceImpl {
}
}
impl ServiceTrait for ExchangeRateServiceImpl {}
#[async_trait::async_trait]
impl ServiceTrait for ExchangeRateServiceImpl {
async fn on_app_start(&self) -> CommandResult<()> {
// Ensure the default adapter is set in settings if not already set
let current_adapter = self
.settings_service
.get_setting(
&Self::get_settings_key(EXCHANGE_ADAPTER_SETTING_KEY),
DEFAULT_ADAPTER_NAME,
)
.await;
if current_adapter.is_empty() {
self.settings_service
.update_setting(
Self::get_settings_key(EXCHANGE_ADAPTER_SETTING_KEY),
DEFAULT_ADAPTER_NAME.to_string(),
None,
)
.await?;
}
Ok(())
}
}
#[async_trait::async_trait]
impl ExchangeRateService for ExchangeRateServiceImpl {