mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 02:33:46 +00:00
[PM-2846][PM-2860] Properly pass region from global to account state (#5764)
* Properly pass region from global to account state * Fixed comment. * Updated logic to not set environment if region with predefined URLs is selected. * Added logic to clear environment URLs in EnvironmentService. * Fixed comment
This commit is contained in:
@@ -286,19 +286,19 @@ export class EnvironmentService implements EnvironmentServiceAbstraction {
|
||||
async setRegion(region: Region) {
|
||||
this.selectedRegion = region;
|
||||
await this.stateService.setRegion(region);
|
||||
switch (region) {
|
||||
case Region.EU:
|
||||
if (region === Region.SelfHosted) {
|
||||
// If user saves a self-hosted region with empty fields, default to US
|
||||
if (this.isEmpty()) {
|
||||
await this.setRegion(Region.US);
|
||||
}
|
||||
} else {
|
||||
// If we are setting the region to EU or US, clear the self-hosted URLs
|
||||
this.stateService.setEnvironmentUrls(new EnvironmentUrls());
|
||||
if (region === Region.EU) {
|
||||
this.setUrlsInternal(this.euUrls);
|
||||
break;
|
||||
case Region.US:
|
||||
} else if (region === Region.US) {
|
||||
this.setUrlsInternal(this.usUrls);
|
||||
break;
|
||||
case Region.SelfHosted:
|
||||
// if user saves with empty fields, default to US
|
||||
if (this.isEmpty()) {
|
||||
await this.setRegion(Region.US);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user