mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-12 00:09:03 +00:00
chore(menu): ensure required mod.json fields exist before attempting render
This commit is contained in:
parent
c6d58f37ee
commit
765e7b738c
@ -22,7 +22,7 @@ const renderOptions = async (mod) => {
|
|||||||
const db = initDatabase([profile, mod.id], await optionDefaults(mod.id));
|
const db = initDatabase([profile, mod.id], await optionDefaults(mod.id));
|
||||||
let options = mod.options.reduce((options, opt, i) => {
|
let options = mod.options.reduce((options, opt, i) => {
|
||||||
if (!opt.key && (opt.type !== "heading" || !opt.label)) return options;
|
if (!opt.key && (opt.type !== "heading" || !opt.label)) return options;
|
||||||
if (opt.targets && !opt.targets.includes(platform)) return options;
|
if (opt.platforms && !opt.platforms.includes(platform)) return options;
|
||||||
const prevOpt = options[options.length - 1];
|
const prevOpt = options[options.length - 1];
|
||||||
// no consective headings
|
// no consective headings
|
||||||
if (opt.type === "heading" && prevOpt?.type === opt.type) {
|
if (opt.type === "heading" && prevOpt?.type === opt.type) {
|
||||||
@ -46,7 +46,17 @@ const renderList = async (mods) => {
|
|||||||
{ isEnabled, initDatabase } = globalThis.__enhancerApi,
|
{ isEnabled, initDatabase } = globalThis.__enhancerApi,
|
||||||
enabledMods = initDatabase([await getProfile(), "enabledMods"]);
|
enabledMods = initDatabase([await getProfile(), "enabledMods"]);
|
||||||
mods = mods
|
mods = mods
|
||||||
.filter((mod) => !mod.platforms || mod.platforms.includes(platform))
|
.filter((mod) => {
|
||||||
|
const required =
|
||||||
|
mod.id &&
|
||||||
|
mod.name &&
|
||||||
|
mod.version &&
|
||||||
|
mod.description &&
|
||||||
|
mod.thumbnail &&
|
||||||
|
mod.authors,
|
||||||
|
compatible = !mod.platforms || mod.platforms.includes(platform);
|
||||||
|
return required && compatible;
|
||||||
|
})
|
||||||
.map(async (mod) => {
|
.map(async (mod) => {
|
||||||
const enabled = await isEnabled(mod.id),
|
const enabled = await isEnabled(mod.id),
|
||||||
_update = (enabled) => enabledMods.set(mod.id, enabled);
|
_update = (enabled) => enabledMods.set(mod.id, enabled);
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
"type": "toggle",
|
"type": "toggle",
|
||||||
"key": "debugMode",
|
"key": "debugMode",
|
||||||
"description": "Activates built-in debugging tools accessible through the application menu.",
|
"description": "Activates built-in debugging tools accessible through the application menu.",
|
||||||
"targets": ["darwin", "win32", "linux"],
|
"platforms": ["darwin", "win32", "linux"],
|
||||||
"value": false
|
"value": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user