mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Adding null checks to prevent runtime exceptions (#22054)
This commit is contained in:
@@ -269,18 +269,25 @@ export class ConnectionConfig {
|
|||||||
subgroups.push(group);
|
subgroups.push(group);
|
||||||
// Get all connections in the settings
|
// Get all connections in the settings
|
||||||
let profiles = this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).userValue;
|
let profiles = this.configurationService.inspect<IConnectionProfileStore[]>(CONNECTIONS_CONFIG_KEY).userValue;
|
||||||
|
|
||||||
|
if (profiles) {
|
||||||
// Remove the profiles from the connections
|
// Remove the profiles from the connections
|
||||||
profiles = profiles!.filter(value => {
|
profiles = profiles!.filter(value => {
|
||||||
let providerConnectionProfile = ConnectionProfile.createFromStoredProfile(value, this._capabilitiesService);
|
let providerConnectionProfile = ConnectionProfile.createFromStoredProfile(value, this._capabilitiesService);
|
||||||
return !connections.some((val) => val.getOptionsKey() === providerConnectionProfile.getOptionsKey());
|
return !connections.some((val) => val.getOptionsKey() === providerConnectionProfile.getOptionsKey());
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Get all groups in the settings
|
// Get all groups in the settings
|
||||||
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).userValue;
|
let groups = this.configurationService.inspect<IConnectionProfileGroup[]>(GROUPS_CONFIG_KEY).userValue;
|
||||||
|
|
||||||
|
if (groups) {
|
||||||
// Remove subgroups in the settings
|
// Remove subgroups in the settings
|
||||||
groups = groups!.filter((grp) => {
|
groups = groups!.filter((grp) => {
|
||||||
return !subgroups.some((item) => item.id === grp.id);
|
return !subgroups.some((item) => item.id === grp.id);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
this.configurationService.updateValue(CONNECTIONS_CONFIG_KEY, profiles, ConfigurationTarget.USER),
|
this.configurationService.updateValue(CONNECTIONS_CONFIG_KEY, profiles, ConfigurationTarget.USER),
|
||||||
this.configurationService.updateValue(GROUPS_CONFIG_KEY, groups, ConfigurationTarget.USER)
|
this.configurationService.updateValue(GROUPS_CONFIG_KEY, groups, ConfigurationTarget.USER)
|
||||||
|
|||||||
Reference in New Issue
Block a user