Skip to content

Lint - #5845

Merged
fregante merged 10 commits into
mainfrom
lint-2008
Aug 1, 2022
Merged

Lint#5845
fregante merged 10 commits into
mainfrom
lint-2008

Conversation

@fregante

@fregante fregante commented Jul 21, 2022 •

Copy link
Copy Markdown
Member

@fregante fregante added the meta Related to Refined GitHub itself label Jul 21, 2022
}
}

const filesRestored = new WeakSet<HTMLButtonElement>();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was needed because we kept the dropdown open, I think. Since the dropdown now closes on click, the user cannot double click. By the time they manage to open the menu and click again, it's probably done and the file is gone.

filesRestored.add(menuItem);

try {
await showToast(async progress => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

showToast already acts as its own try/catch, with errors being shown in the toast itself. No need for an extra try/catch as long as everything is inside.


export function registerHotkey(hotkey: string, action: VoidFunction | string): Deinit {
const element = typeof action === 'string'
? <a hidden href={action} data-hotkey={hotkey}/>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added support for strings, but haven't found any use for it where it would simplify the code.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we treat this string as a selector and do select(action).click()?

To emulate link behavior, just pass an action of () => location.assign(link).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we treat this string as a selector and do select(action).click()?

addHotkey already does that:

registerHotkey('ctrl-a', 'a[blah]') // Your suggestion
addHotkey(select('a[blah]'), 'ctrl-a') // Already-possible solution

To emulate link behavior, just pass an action of () => location.assign(link).

There's no substitute for real links (which can be handled by Turbo as well).

I do see two possible improvements here:

  • make the two functions consistent (always accept "hotkey" first), or
  • merge the two functions so registerHotkey accepts an element passed as "action"

kidonng and others added 4 commits July 27, 2022 13:54
Picked from 1e1887a
Too small a change to be a pull request
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'nextElementSibling')
    at MutationObserver.cleanPrHeader
@fregante
fregante marked this pull request as ready for review August 1, 2022 15:50
@fregante

fregante commented Aug 1, 2022

Copy link
Copy Markdown
Member Author

Will merge within an hour

@fregante
fregante merged commit 54d381a into main Aug 1, 2022
@fregante
fregante deleted the lint-2008 branch August 1, 2022 16:51
@fregante

fregante commented Aug 1, 2022

Copy link
Copy Markdown
Member Author

Screen Shot 18

Screen Shot 19

I let you all down and I apologize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

2 participants