mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-06 18:07:11 +00:00
Fix state changing when selecting region or resetting to global.
This commit is contained in:
parent
6a1ec98dfb
commit
d8f6fd9d23
@ -311,18 +311,18 @@ export const SettingsPane: FunctionComponent<{ explorer: Explorer }> = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check if region selection has been updated. Update database account in user context accordingly.
|
const storedRegion = LocalStorageUtility.getEntryString(StorageKey.SelectedRegion);
|
||||||
// If global is selected, then remove the region selection from local storage.
|
const selectedRegionIsGlobal = selectedRegion === Constants.RegionSelectionOptions.Global;
|
||||||
if (selectedRegion !== LocalStorageUtility.getEntryString(StorageKey.SelectedRegion)) {
|
if (selectedRegionIsGlobal && storedRegion) {
|
||||||
LocalStorageUtility.setEntryString(StorageKey.SelectedRegion, selectedRegion);
|
LocalStorageUtility.removeEntry(StorageKey.SelectedRegion);
|
||||||
let selectedRegionalEndpoint: string | undefined;
|
|
||||||
if (selectedRegion === Constants.RegionSelectionOptions.Global) {
|
|
||||||
selectedRegionalEndpoint = undefined;
|
|
||||||
} else {
|
|
||||||
selectedRegionalEndpoint = regionOptions.find((option) => option.key === selectedRegion)?.data?.endpoint;
|
|
||||||
}
|
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
selectedRegionalEndpoint: selectedRegionalEndpoint,
|
selectedRegionalEndpoint: undefined,
|
||||||
|
refreshCosmosClient: true,
|
||||||
|
});
|
||||||
|
} else if (!selectedRegionIsGlobal && selectedRegion !== storedRegion) {
|
||||||
|
LocalStorageUtility.setEntryString(StorageKey.SelectedRegion, selectedRegion);
|
||||||
|
updateUserContext({
|
||||||
|
selectedRegionalEndpoint: regionOptions.find((option) => option.key === selectedRegion)?.data?.endpoint,
|
||||||
refreshCosmosClient: true,
|
refreshCosmosClient: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user