Skip to content

Reliable merge box handlers - #2019

Merged
fregante merged 9 commits into
masterfrom
reliable-merge-box-handlers
May 17, 2019
Merged

fregante merged 9 commits into
masterfrom
reliable-merge-box-handlers

Conversation

@fregante

@fregante fregante commented May 9, 2019 •

Copy link
Copy Markdown
Member

Depends on sindresorhus/memoize#35

Maybe these could benefit from this as well, once they're merged:

Reason of the changes:

  • details:toggled was unreliable (small fix)
  • fit-textareas was being called from an unrelated feature
  • add-co-authored-by wasn't being added when the session was restored (i.e. type a new PR title and reload the page)
  • add-co-authored-by was listening to a click on a button, which conflicted with the future Add update-pr-from-base-branch feature #1950

fregante added 4 commits May 9, 2019 15:18
And make it more reliable. Firefox and Chrome had opposite `event.detail.open` values
Now also appears after `session:resume` and doesn't add unnecessary line-breaks
@fregante fregante added bug meta Related to Refined GitHub itself cleanup labels May 9, 2019
@fregante fregante mentioned this pull request May 9, 2019
7 tasks done
callback(event);
}
});

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 love this pattern.

Since addEventListener doesn't add the same handler twice, it's important that the same exact handler is passed every time. To do this I always use a WeakMap and an ugly sequence of get or create, then set and return, but I think I finally found a way to hide this complexity with mem.

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.

I like this pattern a lot 👍

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.

Also used here fregante/delegate-it#10

Screenshot 2019-05-17 at 21 58 06

@fregante
fregante marked this pull request as ready for review May 15, 2019 16:05

@fregante fregante left a comment

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 PR is good to go too

@fregante
fregante requested a review from sindresorhus May 15, 2019 16:24
@fregante
fregante merged commit 1e631d2 into master May 17, 2019
@fregante
fregante deleted the reliable-merge-box-handlers branch May 17, 2019 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

2 participants