Skip to content

Commit dbf2246

Browse files
committed
feat(settings/list): allow function to load label
1 parent 6221448 commit dbf2246

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

changelog.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# UnderScript Changelog
22

3-
## Version 0.52.2 (2023-04-15)
4-
1. Added craft/disenchant protection when double clicking
3+
## Version 0.53.0 (2023-05-21)
4+
### New Features
5+
1. Added craft/disenchant protection to prevent double clicking
6+
1. Added new ranks to board background priority
7+
### Fixes
58
1. Fix background of `@autocomplete`
69

710
## Version 0.52.1 (2023-04-05)

src/utils/settings/types/list.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,16 @@ function getValue(item) {
9999
return item;
100100
}
101101

102-
function getLabel(item) {
102+
function getLabel(item,
103+
// allow only one level of function calls
104+
allowed = true) {
105+
if (allowed && typeof item === 'function') {
106+
return getLabel(item(), false);
107+
}
103108
if (typeof item === 'object') {
104-
return item.label || item.text;
109+
return getLabel(item.label || item.text, allowed);
105110
}
111+
if (!item) throw new Error('Label not provided');
112+
if (typeof item !== 'string') throw new Error(`Unknown label: ${typeof item}`);
106113
return item;
107114
}

0 commit comments

Comments
 (0)