Skip to content

Commit

Permalink
Fix #581; Note folder dropdown is empty after folder has been moved
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed May 2, 2024
1 parent edad5d6 commit 9240de9
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions src/settingHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,36 @@ export function createSearchSelect({
el.win.setTimeout(() => {
let list = choices;

const [value, defaultVal] = manager.getSetting(key, local);

if (defaultVal) {
const index = choices.findIndex((f) => f.value === defaultVal);
const choice = choices[index];
const [value, globalValue] = manager.getSetting(key, local);

let didSetPlaceholder = false;
if (globalValue) {
const index = list.findIndex((f) => f.value === globalValue);

if (index > -1) {
didSetPlaceholder = true;
const choice = choices[index];

list = update(list, {
$splice: [[index, 1]],
$unshift: [
update(choice, {
placeholder: {
$set: true,
},
value: {
$set: '',
},
label: {
$apply: (v) => `${v} (${t('default')})`,
},
}),
],
});
}
}

list = update(list, {
$splice: [[index, 1]],
$unshift: [
update(choice, {
placeholder: {
$set: true,
},
value: {
$set: '',
},
label: {
$apply: (v) => `${v} (${t('default')})`,
},
}),
],
});
} else {
if (!didSetPlaceholder) {
list = update(list, {
$unshift: [
{
Expand All @@ -136,7 +143,7 @@ export function createSearchSelect({
choices: list,
}).setChoiceByValue('');

if (value && typeof value === 'string') {
if (value && typeof value === 'string' && list.findIndex((f) => f.value === value) > -1) {
c.setChoiceByValue(value);
}

Expand Down

0 comments on commit 9240de9

Please sign in to comment.