Skip to content

Commit 7750b1b

Browse files
committed
settings: Optimize data chunk
There's ~4000 empty keys, so just need to refactor a few locations to ignore missing keys and we can substantially reduce the size of the chunk.
1 parent e615c29 commit 7750b1b

File tree

5 files changed

+187
-882
lines changed

5 files changed

+187
-882
lines changed

components/SettingsComponent.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ const d = Object.fromEntries(Object.entries(data).filter(([k, v]) =>
2222
/* Filter entries (by plugin or tag). */
2323
((!props.plugin && !tag) ||
2424
(props.plugin &&
25-
(v.plugin && v.plugin.includes(props.plugin))) ||
25+
v.plugin?.includes(props.plugin)) ||
2626
(tag && tag.find((t) =>
27-
(v.plugin && v.plugin.includes(t)) ||
28-
(v.tags.includes(t)))
27+
v.plugin?.includes(t) ||
28+
v.tags?.includes(t))
2929
)) &&
3030
/* Apply filter. */
3131
((filter == 'all') ||
@@ -88,21 +88,21 @@ const d = Object.fromEntries(Object.entries(data).filter(([k, v]) =>
8888
<span class="comma" v-for="v in v.values" v-html="v.url" />
8989
</td>
9090
</tr>
91-
<tr v-if="v.values_enum.length">
91+
<tr v-if="v.values_enum?.length">
9292
<th>Allowed Values</th>
9393
<td>
9494
<span class="comma" v-for="v in v.values_enum.values()"><code>{{ v }}</code></span>
9595
</td>
9696
</tr>
97-
<tr v-if="v.dependencies.length">
97+
<tr v-if="v.dependencies?.length">
9898
<th>Dependencies</th>
9999
<td>
100100
<ul>
101101
<li v-for="v in v.dependencies" v-html="v" />
102102
</ul>
103103
</td>
104104
</tr>
105-
<tr v-if="v.seealso.length">
105+
<tr v-if="v.seealso?.length">
106106
<th>See Also</th>
107107
<td>
108108
<ul>

data/settings.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,8 +2131,7 @@ fts_header_includes {
21312131
fts_header_includes: {
21322132
plugin: 'fts',
21332133
values: setting_types.BOOLLIST,
2134-
seealso: [ 'fts_header_excludes' ],
2135-
text: ``
2134+
seealso: [ 'fts_header_excludes' ]
21362135
},
21372136

21382137
fts_search_timeout: {

lib/settings.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getVitepressMd } from './markdown.js'
22
import { loadData, normalizeArrayData } from './utility.js'
3+
import cleanDeep from 'clean-deep'
34

45
/* List of Dovecot settings value types. */
56
export const setting_types = {
@@ -217,14 +218,22 @@ async function normalizeSettings(settings) {
217218
}
218219
}
219220

220-
v.text = md.render(v.text.trim())
221+
if (v.text) {
222+
v.text = md.render(v.text.trim())
223+
}
221224
}
222225

223226
return data
224227
}
225228

226229
export async function loadSettings() {
227-
return await normalizeSettings(
228-
structuredClone((await loadData('settings')).settings)
230+
return cleanDeep(
231+
await normalizeSettings(
232+
structuredClone((await loadData('settings')).settings)
233+
),
234+
// Clean empty arrays and null values.
235+
// Maintain empty string (""), since it is used for
236+
// certain default settings.
237+
{ emptyStrings: false }
229238
)
230239
}

0 commit comments

Comments
 (0)