mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-11 15:59:03 +00:00
feat(menu): indicate upload status of file inputs with label change
This commit is contained in:
parent
5a91e58104
commit
38b056429e
@ -120,9 +120,19 @@ function Input({
|
|||||||
|
|
||||||
let _initialValue;
|
let _initialValue;
|
||||||
extendProps($input, {
|
extendProps($input, {
|
||||||
|
onclick: () => {
|
||||||
|
// change text to "uploading..." until file has uploaded
|
||||||
|
// to reassure users experiencing latency while file is processed
|
||||||
|
if (type === "file") $filename.innerText = "Uploading...";
|
||||||
|
},
|
||||||
onchange: (event) => {
|
onchange: (event) => {
|
||||||
if (_set && type === "file") {
|
if (_set && type === "file") {
|
||||||
readUpload(event).then(_set);
|
readUpload(event)
|
||||||
|
.then(_set)
|
||||||
|
// refocus iframe after file has uploaded,
|
||||||
|
// sometimes switching back after opening the
|
||||||
|
// native file upload menu causes a loss of focus
|
||||||
|
.then(() => window.focus());
|
||||||
} else _set?.($input.value);
|
} else _set?.($input.value);
|
||||||
},
|
},
|
||||||
onrerender: async () => {
|
onrerender: async () => {
|
||||||
|
@ -42,6 +42,8 @@ function Onboarding() {
|
|||||||
notion-enhancer's privacy policy and terms & conditions.
|
notion-enhancer's privacy policy and terms & conditions.
|
||||||
<//>
|
<//>
|
||||||
<div class="flex items-center my-[14px] gap-[8px]">
|
<div class="flex items-center my-[14px] gap-[8px]">
|
||||||
|
<!-- _requireReload=${false} prevents the footer from
|
||||||
|
suggesting a reload of the app when the box is checked -->
|
||||||
<${Checkbox}
|
<${Checkbox}
|
||||||
_set=${(checked) => ($submitAgreement.disabled = !checked)}
|
_set=${(checked) => ($submitAgreement.disabled = !checked)}
|
||||||
_requireReload=${false}
|
_requireReload=${false}
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
/**
|
|
||||||
* notion-enhancer: menu
|
|
||||||
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
|
||||||
* (https://notion-enhancer.github.io/) under the MIT license
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const notificationsURL = 'https://notion-enhancer.github.io/notifications.json';
|
|
||||||
|
|
||||||
export default async function ({ env, fs, storage, registry, web }, db) {
|
|
||||||
web.addHotkeyListener(await db.get(['hotkey']), env.focusMenu);
|
|
||||||
|
|
||||||
const sidebarSelector = '.notion-sidebar-container .notion-sidebar > div:nth-child(3) > div > div:nth-child(2)';
|
|
||||||
await web.whenReady([sidebarSelector]);
|
|
||||||
|
|
||||||
const $sidebarLink = web.html`<div class="enhancer--sidebarMenuLink" role="button" tabindex="0">
|
|
||||||
<div>
|
|
||||||
<div>${await fs.getText('media/colour.svg')}</div>
|
|
||||||
<div><div>notion-enhancer</div></div>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
$sidebarLink.addEventListener('click', env.focusMenu);
|
|
||||||
|
|
||||||
const notifications = {
|
|
||||||
cache: await storage.get(['notifications'], []),
|
|
||||||
provider: await fs.getJSON(notificationsURL),
|
|
||||||
count: (await registry.errors()).length,
|
|
||||||
};
|
|
||||||
for (const notification of notifications.provider) {
|
|
||||||
if (
|
|
||||||
!notifications.cache.includes(notification.id) &&
|
|
||||||
notification.version === env.version &&
|
|
||||||
(!notification.environments || notification.environments.includes(env.name))
|
|
||||||
) {
|
|
||||||
notifications.count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((await storage.get(['last_read_changelog'])) !== env.version) notifications.count++;
|
|
||||||
if (notifications.count) {
|
|
||||||
web.render(
|
|
||||||
$sidebarLink.children[0],
|
|
||||||
web.html`<div class="enhancer--notificationBubble"><div><span>${notifications.count}</span></div></div>`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
web.render(document.querySelector(sidebarSelector), $sidebarLink);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user