Skip to content

Commit

Permalink
Provide default location
Browse files Browse the repository at this point in the history
Refs: #56
  • Loading branch information
orontee committed Oct 9, 2023
1 parent c47fa49 commit 0d6788b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions src/app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,19 @@ void App::setup() {
return;
}
this->ui = std::make_unique<Ui>(this->model);
this->load_config();

auto &current_location = this->model->location;
if (current_location.name.empty()) {
current_location.longitude = 2.3200410217200766;
current_location.latitude = 48.858889699999999;
current_location.name = "Paris";
current_location.country = "FR";
current_location.state = "Ile-de-France";
}

BOOST_LOG_TRIVIAL(info)
<< "First load of configuration asked to trigger a data refresh";
this->load_config(true);
}

void App::show() {
Expand All @@ -99,7 +111,7 @@ void App::initialize_language() {
this->language = currentLang();
initialize_translations();
}
void App::load_config() {
void App::load_config(bool force_data_refresh) {
BOOST_LOG_TRIVIAL(debug) << "Loading config";

Config config;
Expand Down Expand Up @@ -136,8 +148,8 @@ void App::load_config() {
initialize_translations();
}

const bool is_data_obsolete =
is_api_key_obsolete or is_unit_system_obsolete or is_language_obsolete;
const bool is_data_obsolete = force_data_refresh or is_api_key_obsolete or
is_unit_system_obsolete or is_language_obsolete;
// temperatures, wind speed and weather description are computed
// by the backend thus unit system or language change implies that
// data are obsolete
Expand Down
2 changes: 1 addition & 1 deletion src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class App {

void initialize_language();

void load_config();
void load_config(bool force_data_refresh = false);

int handle_custom_event(int param_one, int param_two);

Expand Down

0 comments on commit 0d6788b

Please sign in to comment.