platform-specific option overrides for features not required on macOS

This commit is contained in:
dragonwocky 2020-10-28 12:19:39 +11:00
parent 64c88f5c42
commit 29ef9a57b8
Signed by: dragonwocky
GPG Key ID: C7A48B7846AA706D
7 changed files with 39 additions and 10 deletions

View File

@ -25,6 +25,7 @@ a flexibility update.
- improved: overwrite `app.asar.bak` if already exists (e.g. for app updates). - improved: overwrite `app.asar.bak` if already exists (e.g. for app updates).
- improved: additional menu option descriptions on hover. - improved: additional menu option descriptions on hover.
- improved: listen to prefers-color-scheme to better change theme in night shift. - 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: removed messenger emoji set as the provider no longer supports it.
- bugfix: remove shadow around light mode board headers. - bugfix: remove shadow around light mode board headers.
- bugfix: properly detect/respond to `EACCES`/`EBUSY` errors. - bugfix: properly detect/respond to `EACCES`/`EBUSY` errors.

View File

@ -25,20 +25,24 @@ join the [discord server](https://discord.gg/sFWPXtA).
## testing ## testing
download: first, remove any other installations of the enhancer: `npm remove -g notion-enhancer`
to download and install the latest code, run:
```sh ```sh
git clone https://github.com/dragonwocky/notion-enhancer git clone https://github.com/dragonwocky/notion-enhancer
cd notion-enhancer cd notion-enhancer
git checkout dev git checkout dev
npm link 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: ```sh
i don't have the experience/skill with them yet to use them effectively. notion-enhancer remove -n
if you can add some for your code, though, go ahead! npm unlink
```
## conventions ## conventions

View File

@ -587,6 +587,13 @@ window['__start'] = async () => {
const $options = mod.elem.querySelector('.options'); const $options = mod.elem.querySelector('.options');
if ($options) if ($options)
for (const opt of mod.options) { for (const opt of mod.options) {
if (
Object.keys(opt.platformOverwrite || {}).some(
(platform) => process.platform === platform
)
) {
continue;
}
const $opt = createOption(opt, mod.id); const $opt = createOption(opt, mod.id);
if (opt.type === 'color') { if (opt.type === 'color') {
const $preview = $opt.querySelector('input'); const $preview = $opt.querySelector('input');

View File

@ -46,6 +46,9 @@ module.exports = {
it can be re-shown by clicking the tray icon or using the hotkey.`, it can be re-shown by clicking the tray icon or using the hotkey.`,
type: 'toggle', type: 'toggle',
value: true, value: true,
platformOverwrite: {
darwin: true,
},
}, },
{ {
key: 'frameless', key: 'frameless',
@ -53,6 +56,9 @@ module.exports = {
description: `replace the native titlebar with buttons inset into the app.`, description: `replace the native titlebar with buttons inset into the app.`,
type: 'toggle', type: 'toggle',
value: true, value: true,
platformOverwrite: {
darwin: false,
},
}, },
{ {
key: 'tiling_mode', key: 'tiling_mode',

View File

@ -22,6 +22,9 @@ module.exports = {
used to drag/move the window.`, used to drag/move the window.`,
type: 'input', type: 'input',
value: 15, value: 15,
platformOverwrite: {
darwin: 0,
},
}, },
{ {
key: 'responsive_breakpoint', key: 'responsive_breakpoint',

View File

@ -9,7 +9,7 @@
"scripts": { "scripts": {
"test": "echo \"no test specified\"", "test": "echo \"no test specified\"",
"postinstall": "node bin.js apply -y", "postinstall": "node bin.js apply -y",
"preuninstall": "node bin.js remove" "preuninstall": "node bin.js remove -n"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -133,10 +133,18 @@ function getEnhancements() {
) )
throw Error; throw Error;
mod.defaults = {}; mod.defaults = {};
for (let opt of mod.options || []) for (let opt of mod.options || []) {
mod.defaults[opt.key] = Array.isArray(opt.value) if (
? opt.value[0] Object.keys(opt.platformOverwrite || {}).some(
: opt.value; (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.IDs.push(mod.id);
modules.loaded.push({ modules.loaded.push({
...mod, ...mod,