From 29ef9a57b8a0e34489bb28f205e9ef36bb0bb07f Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Wed, 28 Oct 2020 12:19:39 +1100 Subject: [PATCH] platform-specific option overrides for features not required on macOS --- CHANGELOG.md | 1 + CONTRIBUTING.md | 14 +++++++++----- mods/core/enhancerMenu.js | 7 +++++++ mods/core/mod.js | 6 ++++++ mods/tweaks/mod.js | 3 +++ package.json | 2 +- pkg/helpers.js | 16 ++++++++++++---- 7 files changed, 39 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff41253..7c38911 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ a flexibility update. - improved: overwrite `app.asar.bak` if already exists (e.g. for app updates). - improved: additional menu option descriptions on hover. - improved: listen to prefers-color-scheme to better change theme in night shift. +- improved: platform-specific option overrides for features not required on macOS. - bugfix: removed messenger emoji set as the provider no longer supports it. - bugfix: remove shadow around light mode board headers. - bugfix: properly detect/respond to `EACCES`/`EBUSY` errors. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4d3399c..035439f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,20 +25,24 @@ join the [discord server](https://discord.gg/sFWPXtA). ## testing -download: +first, remove any other installations of the enhancer: `npm remove -g notion-enhancer` + +to download and install the latest code, run: ```sh git clone https://github.com/dragonwocky/notion-enhancer cd notion-enhancer git checkout dev npm link +notion-enhancer apply -y ``` -the downloaded folder is now directly linked to the `notion-enhancer` command. +to remove the dev build, go into the downloaded folder and run: -no written tests are included with the enhancer: -i don't have the experience/skill with them yet to use them effectively. -if you can add some for your code, though, go ahead! +```sh +notion-enhancer remove -n +npm unlink +``` ## conventions diff --git a/mods/core/enhancerMenu.js b/mods/core/enhancerMenu.js index 7b3b706..7242f03 100644 --- a/mods/core/enhancerMenu.js +++ b/mods/core/enhancerMenu.js @@ -587,6 +587,13 @@ window['__start'] = async () => { const $options = mod.elem.querySelector('.options'); if ($options) for (const opt of mod.options) { + if ( + Object.keys(opt.platformOverwrite || {}).some( + (platform) => process.platform === platform + ) + ) { + continue; + } const $opt = createOption(opt, mod.id); if (opt.type === 'color') { const $preview = $opt.querySelector('input'); diff --git a/mods/core/mod.js b/mods/core/mod.js index 4772901..61cd942 100644 --- a/mods/core/mod.js +++ b/mods/core/mod.js @@ -46,6 +46,9 @@ module.exports = { it can be re-shown by clicking the tray icon or using the hotkey.`, type: 'toggle', value: true, + platformOverwrite: { + darwin: true, + }, }, { key: 'frameless', @@ -53,6 +56,9 @@ module.exports = { description: `replace the native titlebar with buttons inset into the app.`, type: 'toggle', value: true, + platformOverwrite: { + darwin: false, + }, }, { key: 'tiling_mode', diff --git a/mods/tweaks/mod.js b/mods/tweaks/mod.js index 0c538fb..7d7e839 100644 --- a/mods/tweaks/mod.js +++ b/mods/tweaks/mod.js @@ -22,6 +22,9 @@ module.exports = { used to drag/move the window.`, type: 'input', value: 15, + platformOverwrite: { + darwin: 0, + }, }, { key: 'responsive_breakpoint', diff --git a/package.json b/package.json index a71d9c9..9e121d2 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "scripts": { "test": "echo \"no test specified\"", "postinstall": "node bin.js apply -y", - "preuninstall": "node bin.js remove" + "preuninstall": "node bin.js remove -n" }, "repository": { "type": "git", diff --git a/pkg/helpers.js b/pkg/helpers.js index 46dc300..b3d4872 100644 --- a/pkg/helpers.js +++ b/pkg/helpers.js @@ -133,10 +133,18 @@ function getEnhancements() { ) throw Error; mod.defaults = {}; - for (let opt of mod.options || []) - mod.defaults[opt.key] = Array.isArray(opt.value) - ? opt.value[0] - : opt.value; + for (let opt of mod.options || []) { + if ( + Object.keys(opt.platformOverwrite || {}).some( + (platform) => process.platform === platform + ) + ) { + mod.defaults[opt.key] = opt.platformOverwrite[process.platform]; + } else + mod.defaults[opt.key] = Array.isArray(opt.value) + ? opt.value[0] + : opt.value; + } modules.IDs.push(mod.id); modules.loaded.push({ ...mod,