mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-16 18:09:01 +00:00
scope all await statements
This commit is contained in:
parent
496305597a
commit
a72441ee86
repo
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
import { fmt, web, registry, components } from '../../api/_.mjs';
|
import { fmt, web, registry, components } from '../../api/_.mjs';
|
||||||
import { notifications } from './notifications.mjs';
|
import { notifications } from './notifications.mjs';
|
||||||
const profileDB = await registry.profileDB();
|
|
||||||
|
|
||||||
export const modComponents = {
|
export const modComponents = {
|
||||||
preview: (url) => web.html`<img
|
preview: (url) => web.html`<img
|
||||||
@ -56,7 +55,8 @@ export const modComponents = {
|
|||||||
|
|
||||||
export const options = {
|
export const options = {
|
||||||
toggle: async (mod, opt) => {
|
toggle: async (mod, opt) => {
|
||||||
const checked = await profileDB.get([mod.id, opt.key], opt.value),
|
const profileDB = await registry.profileDB(),
|
||||||
|
checked = await profileDB.get([mod.id, opt.key], opt.value),
|
||||||
$toggle = modComponents.toggle(opt.label, checked),
|
$toggle = modComponents.toggle(opt.label, checked),
|
||||||
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
||||||
$label = $toggle.children[0],
|
$label = $toggle.children[0],
|
||||||
@ -71,8 +71,10 @@ export const options = {
|
|||||||
});
|
});
|
||||||
return $toggle;
|
return $toggle;
|
||||||
},
|
},
|
||||||
|
|
||||||
select: async (mod, opt) => {
|
select: async (mod, opt) => {
|
||||||
const value = await profileDB.get([mod.id, opt.key], opt.values[0]),
|
const profileDB = await registry.profileDB(),
|
||||||
|
value = await profileDB.get([mod.id, opt.key], opt.values[0]),
|
||||||
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
||||||
$label = web.render(
|
$label = web.render(
|
||||||
web.html`<label class="input-label"></label>`,
|
web.html`<label class="input-label"></label>`,
|
||||||
@ -96,8 +98,10 @@ export const options = {
|
|||||||
});
|
});
|
||||||
return web.render($label, $select, $icon);
|
return web.render($label, $select, $icon);
|
||||||
},
|
},
|
||||||
|
|
||||||
text: async (mod, opt) => {
|
text: async (mod, opt) => {
|
||||||
const value = await profileDB.get([mod.id, opt.key], opt.value),
|
const profileDB = await registry.profileDB(),
|
||||||
|
value = await profileDB.get([mod.id, opt.key], opt.value),
|
||||||
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
||||||
$label = web.render(
|
$label = web.render(
|
||||||
web.html`<label class="input-label"></label>`,
|
web.html`<label class="input-label"></label>`,
|
||||||
@ -112,8 +116,10 @@ export const options = {
|
|||||||
});
|
});
|
||||||
return web.render($label, $input, $icon);
|
return web.render($label, $input, $icon);
|
||||||
},
|
},
|
||||||
|
|
||||||
number: async (mod, opt) => {
|
number: async (mod, opt) => {
|
||||||
const value = await profileDB.get([mod.id, opt.key], opt.value),
|
const profileDB = await registry.profileDB(),
|
||||||
|
value = await profileDB.get([mod.id, opt.key], opt.value),
|
||||||
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
||||||
$label = web.render(
|
$label = web.render(
|
||||||
web.html`<label class="input-label"></label>`,
|
web.html`<label class="input-label"></label>`,
|
||||||
@ -128,8 +134,10 @@ export const options = {
|
|||||||
});
|
});
|
||||||
return web.render($label, $input, $icon);
|
return web.render($label, $input, $icon);
|
||||||
},
|
},
|
||||||
|
|
||||||
color: async (mod, opt) => {
|
color: async (mod, opt) => {
|
||||||
const value = await profileDB.get([mod.id, opt.key], opt.value),
|
const profileDB = await registry.profileDB(),
|
||||||
|
value = await profileDB.get([mod.id, opt.key], opt.value),
|
||||||
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
||||||
$label = web.render(
|
$label = web.render(
|
||||||
web.html`<label class="input-label"></label>`,
|
web.html`<label class="input-label"></label>`,
|
||||||
@ -166,8 +174,10 @@ export const options = {
|
|||||||
paint();
|
paint();
|
||||||
return web.render($label, $input, $icon);
|
return web.render($label, $input, $icon);
|
||||||
},
|
},
|
||||||
|
|
||||||
file: async (mod, opt) => {
|
file: async (mod, opt) => {
|
||||||
const { filename } = (await profileDB.get([mod.id, opt.key], {})) || {},
|
const profileDB = await registry.profileDB(),
|
||||||
|
{ filename } = (await profileDB.get([mod.id, opt.key], {})) || {},
|
||||||
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
||||||
$label = web.render(
|
$label = web.render(
|
||||||
web.html`<label class="input-label"></label>`,
|
web.html`<label class="input-label"></label>`,
|
||||||
@ -204,8 +214,10 @@ export const options = {
|
|||||||
$latest
|
$latest
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
hotkey: async (mod, opt) => {
|
hotkey: async (mod, opt) => {
|
||||||
const value = await profileDB.get([mod.id, opt.key], opt.value),
|
const profileDB = await registry.profileDB(),
|
||||||
|
value = await profileDB.get([mod.id, opt.key], opt.value),
|
||||||
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
|
||||||
$label = web.render(
|
$label = web.render(
|
||||||
web.html`<label class="input-label"></label>`,
|
web.html`<label class="input-label"></label>`,
|
||||||
|
@ -8,6 +8,11 @@
|
|||||||
|
|
||||||
import * as api from '../../api/_.mjs';
|
import * as api from '../../api/_.mjs';
|
||||||
import { notifications, $changelogModal } from './notifications.mjs';
|
import { notifications, $changelogModal } from './notifications.mjs';
|
||||||
|
import { modComponents, options } from './components.mjs';
|
||||||
|
import * as router from './router.mjs';
|
||||||
|
import './styles.mjs';
|
||||||
|
|
||||||
|
(async () => {
|
||||||
const { env, fs, storage, registry, web, components } = api;
|
const { env, fs, storage, registry, web, components } = api;
|
||||||
|
|
||||||
for (const mod of await registry.list((mod) => registry.enabled(mod.id))) {
|
for (const mod of await registry.list((mod) => registry.enabled(mod.id))) {
|
||||||
@ -30,10 +35,6 @@ if (errors.length) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
import { modComponents, options } from './components.mjs';
|
|
||||||
import * as router from './router.mjs';
|
|
||||||
import './styles.mjs';
|
|
||||||
|
|
||||||
const db = await registry.db('a6621988-551d-495a-97d8-3c568bca2e9e'),
|
const db = await registry.db('a6621988-551d-495a-97d8-3c568bca2e9e'),
|
||||||
profileName = await registry.profileName(),
|
profileName = await registry.profileName(),
|
||||||
profileDB = await registry.profileDB();
|
profileDB = await registry.profileDB();
|
||||||
@ -203,7 +204,13 @@ const openProfileMenu = async () => {
|
|||||||
$edit,
|
$edit,
|
||||||
web.html`${await components.feather('type', { class: 'input-icon' })}`
|
web.html`${await components.feather('type', { class: 'input-icon' })}`
|
||||||
),
|
),
|
||||||
web.render(web.html`<p class="profile-actions"></p>`, $export, $import, $save, $delete),
|
web.render(
|
||||||
|
web.html`<p class="profile-actions"></p>`,
|
||||||
|
$export,
|
||||||
|
$import,
|
||||||
|
$save,
|
||||||
|
$delete
|
||||||
|
),
|
||||||
$error
|
$error
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -451,3 +458,4 @@ async function openSidebarMenu(id) {
|
|||||||
openProfileMenu();
|
openProfileMenu();
|
||||||
} else openModMenu(id);
|
} else openModMenu(id);
|
||||||
}
|
}
|
||||||
|
})();
|
||||||
|
@ -10,8 +10,6 @@ import { tw } from './styles.mjs';
|
|||||||
const notificationsURL = 'https://notion-enhancer.github.io/notifications.json';
|
const notificationsURL = 'https://notion-enhancer.github.io/notifications.json';
|
||||||
export const notifications = {
|
export const notifications = {
|
||||||
$container: web.html`<div class="notifications-container"></div>`,
|
$container: web.html`<div class="notifications-container"></div>`,
|
||||||
cache: await storage.get(['notifications'], []),
|
|
||||||
provider: await fs.getJSON(notificationsURL),
|
|
||||||
async add({ icon, message, id = undefined, color = undefined, link = undefined }) {
|
async add({ icon, message, id = undefined, color = undefined, link = undefined }) {
|
||||||
const $notification = link
|
const $notification = link
|
||||||
? web.html`<a
|
? web.html`<a
|
||||||
@ -59,6 +57,11 @@ export const notifications = {
|
|||||||
$notification.addEventListener('click', env.reload);
|
$notification.addEventListener('click', env.reload);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
notifications.cache = await storage.get(['notifications'], []);
|
||||||
|
notifications.provider = await fs.getJSON(notificationsURL);
|
||||||
|
|
||||||
web.render(document.body, notifications.$container);
|
web.render(document.body, notifications.$container);
|
||||||
for (const notification of notifications.provider) {
|
for (const notification of notifications.provider) {
|
||||||
const cached = notifications.cache.includes(notification.id),
|
const cached = notifications.cache.includes(notification.id),
|
||||||
@ -66,15 +69,25 @@ for (const notification of notifications.provider) {
|
|||||||
envMatches = !notification.environments || notification.environments.includes(env.name);
|
envMatches = !notification.environments || notification.environments.includes(env.name);
|
||||||
if (!cached && versionMatches && envMatches) notifications.add(notification);
|
if (!cached && versionMatches && envMatches) notifications.add(notification);
|
||||||
}
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
const lastReadChangelog = await storage.get(['last_read_changelog']),
|
|
||||||
$changelogModalButton = web.html`<button type="button" class="modal-button">
|
|
||||||
Accept & Continue
|
|
||||||
</button>`;
|
|
||||||
export const $changelogModal = web.render(
|
export const $changelogModal = web.render(
|
||||||
web.html`<div class="modal" role="dialog" aria-modal="true">
|
web.html`<div class="modal" role="dialog" aria-modal="true">
|
||||||
<div class="modal-overlay" aria-hidden="true"></div>
|
<div class="modal-overlay" aria-hidden="true"></div>
|
||||||
</div>`,
|
</div>`
|
||||||
|
);
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const $changelogModalButton = web.html`<button type="button" class="modal-button">
|
||||||
|
Accept & Continue
|
||||||
|
</button>`;
|
||||||
|
$changelogModalButton.addEventListener('click', async () => {
|
||||||
|
$changelogModal.classList.remove('modal-visible');
|
||||||
|
await storage.set(['last_read_changelog'], env.version);
|
||||||
|
});
|
||||||
|
|
||||||
|
web.render(
|
||||||
|
$changelogModal,
|
||||||
web.render(
|
web.render(
|
||||||
web.html`<div class="modal-box"></div>`,
|
web.html`<div class="modal-box"></div>`,
|
||||||
web.html`<div class="modal-body">
|
web.html`<div class="modal-body">
|
||||||
@ -152,11 +165,10 @@ export const $changelogModal = web.render(
|
|||||||
web.render(web.html`<div class="modal-actions"></div>`, $changelogModalButton)
|
web.render(web.html`<div class="modal-actions"></div>`, $changelogModalButton)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const lastReadChangelog = await storage.get(['last_read_changelog']);
|
||||||
web.render(document.body, $changelogModal);
|
web.render(document.body, $changelogModal);
|
||||||
if (lastReadChangelog !== env.version) {
|
if (lastReadChangelog !== env.version) {
|
||||||
$changelogModal.classList.add('modal-visible');
|
$changelogModal.classList.add('modal-visible');
|
||||||
}
|
}
|
||||||
$changelogModalButton.addEventListener('click', async () => {
|
})();
|
||||||
$changelogModal.classList.remove('modal-visible');
|
|
||||||
await storage.set(['last_read_changelog'], env.version);
|
|
||||||
});
|
|
||||||
|
@ -165,7 +165,7 @@ body,
|
|||||||
.notion-body.dark
|
.notion-body.dark
|
||||||
.notion-default-overlay-container
|
.notion-default-overlay-container
|
||||||
[style*='grid-template-columns: [boolean-start] 60px [boolean-end property-start] 120px [property-end opererator-start] 110px [operator-end value-start] auto [value-end menu-start] 32px [menu-end];'],
|
[style*='grid-template-columns: [boolean-start] 60px [boolean-end property-start] 120px [property-end opererator-start] 110px [operator-end value-start] auto [value-end menu-start] 32px [menu-end];'],
|
||||||
.notion-focusable[style*='background: rgb(80, 85, 88);'],
|
.notion-focusable[style*='background: rgb(80, 85, 88);']:not(.notion-help-button):not(.onboarding-checklist-button),
|
||||||
.notion-body:not(.dark)
|
.notion-body:not(.dark)
|
||||||
.notion-default-overlay-container
|
.notion-default-overlay-container
|
||||||
[style*='grid-template-columns: [boolean-start] 60px [boolean-end property-start] 120px [property-end opererator-start] 110px [operator-end value-start] auto [value-end menu-start] 32px [menu-end];']
|
[style*='grid-template-columns: [boolean-start] 60px [boolean-end property-start] 120px [property-end opererator-start] 110px [operator-end value-start] auto [value-end menu-start] 32px [menu-end];']
|
||||||
|
Loading…
Reference in New Issue
Block a user