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: 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.

View File

@ -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

View File

@ -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');

View File

@ -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',

View File

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

View File

@ -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",

View File

@ -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,