Skip to content

Commit

Permalink
Simplify initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-snake committed Jan 14, 2025
1 parent 8313d15 commit e52ce03
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/internet_identity/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,21 +388,20 @@ fn post_upgrade(maybe_arg: Option<InternetIdentityInit>) {
}

fn initialize(maybe_arg: Option<InternetIdentityInit>) {
let state_related_origins = persistent_state(|storage| storage.related_origins.clone());
let related_origins = maybe_arg
.clone()
.map(|arg| arg.related_origins)
.unwrap_or(state_related_origins);
let state_openid_google_client_id =
persistent_state(|storage| storage.openid_google_client_id.clone());
let openid_google_client_id = maybe_arg
.clone()
.map(|arg| arg.openid_google_client_id)
.unwrap_or(state_openid_google_client_id);
let related_origins = maybe_arg.clone().map_or_else(
|| persistent_state(|storage| storage.related_origins.clone()),
|arg| arg.related_origins,
);
let openid_google_client_id = maybe_arg.clone().map_or_else(
|| persistent_state(|storage| storage.openid_google_client_id.clone()),
|arg| arg.openid_google_client_id,
);
init_assets(related_origins);
apply_install_arg(maybe_arg);
update_root_hash();
openid_google_client_id.map(openid::setup_google);
if let Some(client_id) = openid_google_client_id {
openid::setup_google(client_id);
}
}

fn apply_install_arg(maybe_arg: Option<InternetIdentityInit>) {
Expand Down

0 comments on commit e52ce03

Please sign in to comment.