Fix review comments

This commit is contained in:
Cohee 2024-09-07 21:08:37 +03:00
parent 1af59f303f
commit 00f6941e93

View File

@ -52,7 +52,7 @@ const FANCY_NAMES = {
/** @type {() => SlashCommandEnumValue[]} */ /** @type {() => SlashCommandEnumValue[]} */
const profilesProvider = () => [ const profilesProvider = () => [
new SlashCommandEnumValue(NONE, NONE), new SlashCommandEnumValue(NONE, NONE),
...extension_settings.connectionManager.profiles.map(p => new SlashCommandEnumValue(p.name, p.name, enumTypes.name, enumIcons.server)), ...extension_settings.connectionManager.profiles.map(p => new SlashCommandEnumValue(p.name, null, enumTypes.name, enumIcons.server)),
]; ];
/** /**
@ -309,6 +309,11 @@ async function renderDetailsContent(details, detailsContent) {
saveSettingsDebounced(); saveSettingsDebounced();
await renderDetailsContent(details, detailsContent); await renderDetailsContent(details, detailsContent);
// None option selected
if (!profileId) {
return;
}
const profile = extension_settings.connectionManager.profiles.find(p => p.id === profileId); const profile = extension_settings.connectionManager.profiles.find(p => p.id === profileId);
if (!profile) { if (!profile) {
@ -455,11 +460,13 @@ async function renderDetailsContent(details, detailsContent) {
const selectedProfile = extension_settings.connectionManager.selectedProfile; const selectedProfile = extension_settings.connectionManager.selectedProfile;
const profile = extension_settings.connectionManager.profiles.find(p => p.id === selectedProfile); const profile = extension_settings.connectionManager.profiles.find(p => p.id === selectedProfile);
if (!profile) { if (!profile) {
toastr.warning('No profile selected.');
return ''; return '';
} }
await updateConnectionProfile(profile); await updateConnectionProfile(profile);
await renderDetailsContent(details, detailsContent); await renderDetailsContent(details, detailsContent);
saveSettingsDebounced(); saveSettingsDebounced();
return profile.name;
}, },
})); }));