Skip to content

Add user-local-time feature - #2549

Merged
fregante merged 24 commits into
refined-github:masterfrom
dertieran:show-local-user-time
Nov 29, 2019
Merged

fregante merged 24 commits into
refined-github:masterfrom
dertieran:show-local-user-time

Conversation

@dertieran

@dertieran dertieran commented Nov 18, 2019 •

Copy link
Copy Markdown
Contributor

This is the first implementation of adding the user's time to their hovercard.
This is done through checking their last commit author date.

Screenshot

image

It is still a bit rough implementation and might not be final.

Todos:

  • Should the custom api be handled here or extracted out
  • How should errors be handled?
    Right now most of them just result into an empty time (that is also chached).

Closes #1233

This is the first implementation of adding the user's time to their hovercard.
This is done through checking their last commit author date.

It is still a bit rough implementation and might not be final.
@fregante

This comment has been minimized.

@dertieran

This comment has been minimized.

@fregante

This comment has been minimized.

@dertieran

dertieran commented Nov 23, 2019 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review, will go through it 👍

Just noticed another problem:
@fregante latest push event commit is a merge commit.
But the patch file for that commit doesn't contain the merge commit and so the wrong date is parsed.
So another special case that needs to be hanled 😄
(Probably by checking if the sha is actually in the patch)

@fregante

Copy link
Copy Markdown
Member

But the patch file for that commit doesn't contain the merge commit and so the wrong date is parsed.

This means that fetch patch needs to be part of the loop, right? if fetch(patch) === mergeCommit, continue

@dertieran

dertieran commented Nov 23, 2019 •

Copy link
Copy Markdown
Contributor Author

This means that fetch patch needs to be part of the loop, right? if fetch(patch) === mergeCommit, continue

Yes I think that's the solution.
Hope a simple patch.includes(sha) will be enough.

@dertieran

dertieran commented Nov 26, 2019 •

Copy link
Copy Markdown
Contributor Author

@fregante I moved everything into libs/api in ad21c0d.

I wasn't sure how to make the iterator work without TS yelling so I did this instead.
ad21c0d#diff-ff9c56fbc6853a2fe824e59740b4d7f1L57-L61

Happy for any suggestions to make this work with TS 😄

@fregante fregante self-assigned this Nov 26, 2019

@fregante fregante left a comment

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.

Thanks for the changes! It's looking good!

Comment thread source/libs/api.ts Resolved
Comment thread source/content.ts Resolved
@fregante fregante removed their assignment Nov 26, 2019
@fregante fregante changed the title First implementation of user time Add user-local-time feature Nov 26, 2019
@fregante

fregante commented Nov 26, 2019 •

Copy link
Copy Markdown
Member

I think now only this is left:

I left a fetch logging in there to have an idea of how many requests will happen in practice.

Comment thread source/libs/api.ts Resolved
Comment thread source/libs/api.ts Resolved
Use URL to construct the url and handle empty text response correctly.
This also now exposes the api.getError function to throw any other error.
@dertieran
dertieran marked this pull request as ready for review November 28, 2019 12:40
@dertieran

Copy link
Copy Markdown
Contributor Author

Added the webext-storage-cache 👍
Right now I only cache the date string from the patch (if one was found).

@fregante fregante self-assigned this Nov 29, 2019
@fregante

Copy link
Copy Markdown
Member

@fregante fregante removed their assignment Nov 29, 2019
@fregante
fregante merged commit 45d4eae into refined-github:master Nov 29, 2019
@fregante

Copy link
Copy Markdown
Member

Thank you for this PR @dertieran! 🕙

As expected in some cases this triggers a looot of requests, for example @pento triggers 44 requests: https://github.com/sindresorhus/refined-github/pulls?utf8=%E2%9C%93&q=is%3Apr+author%3Apento

For this reason caching is vital and there are further improvements possible, if anyone wants to improve it.

  • Display progress (for example add a dot for every fetch, . .. ... . .. etc)
  • Pause the loop when the hovercard isn't visible (this might be tricky when coupled with the caching)
  • Also display it on profiles like linkify-user-location

@dertieran
dertieran deleted the show-local-user-time branch November 29, 2019 11:36
@fregante fregante mentioned this pull request Dec 18, 2019
@yakov116

Copy link
Copy Markdown
Member

@dertieran

content.js:9484 Uncaught (in promise) TypeError: Cannot read property 'append' of null
    at MutationObserver.<anonymous> (content.js:9484)

When hovering over the contributors on the main repo page

Looks like thisselector needs to be more specific

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

Development

Successfully merging this pull request may close these issues.

Add local time to hover cards based on user location

4 participants