This commit is contained in:
Mars 2025-05-11 00:39:46 -04:00
parent 867bab1050
commit fc69565f4d

View file

@ -71,6 +71,7 @@ namespace os {
using enum std::launch;
using package::GetTotalCount;
using util::types::Future, util::types::Err;
using enum util::error::DracErrorCode;
Future<Result<String>> hostFut = std::async(async, GetHost);
Future<Result<String>> kernelFut = std::async(async, GetKernelVersion);
@ -85,12 +86,9 @@ namespace os {
Future<Result<weather::WeatherReport>> wthrFut = std::async(config.weather.enabled ? async : deferred, [&config]() -> Result<weather::WeatherReport> {
return config.weather.enabled && config.weather.service
? config.weather.service->getWeatherInfo()
: Err(DracError(util::error::DracErrorCode::ApiUnavailable, "Weather API disabled"));
: Err(DracError(ApiUnavailable, "Weather API disabled"));
});
{
using enum util::error::DracErrorCode;
this->date = getDate();
this->host = hostFut.get();
this->kernelVersion = kernelFut.get();
@ -101,8 +99,7 @@ namespace os {
this->diskUsage = diskFut.get();
this->shell = shellFut.get();
this->packageCount = pkgFut.get();
this->weather = config.weather.enabled ? wthrFut.get() : Err(DracError(util::error::DracErrorCode::ApiUnavailable, "Weather API disabled"));
this->nowPlaying = config.nowPlaying.enabled ? npFut.get() : Err(DracError(util::error::DracErrorCode::ApiUnavailable, "Now Playing API disabled"));
}
this->weather = config.weather.enabled ? wthrFut.get() : Err(DracError(ApiUnavailable, "Weather API disabled"));
this->nowPlaying = config.nowPlaying.enabled ? npFut.get() : Err(DracError(ApiUnavailable, "Now Playing API disabled"));
}
} // namespace os