Skip to content

Extend user-local-time to user profiles - #5779

Merged
kidonng merged 4 commits into
mainfrom
user-local-time
Jul 5, 2022
Merged

kidonng merged 4 commits into
mainfrom
user-local-time

Conversation

@kidonng

@kidonng kidonng commented Jul 4, 2022 •

Copy link
Copy Markdown
Member

Resolve #5775

A lot of dup code, get this thing out first

Test URLs

https://github.com/fregante

Screenshot

Comment thread source/features/user-local-time.tsx Resolved
@fregante

fregante commented Jul 5, 2022

Copy link
Copy Markdown
Member

The structure looks about right. If we had something like Preact it’d be presumably easier to handle this sort of content.

I wonder if attachElement would make this somewhat easier, where you have an intermediary function which calls attachElement with the time-getter logic inside the getNewElement callback.

onHovercardOpen
  append(user, hovercardLocation)

onProfileLoad
  append(user, profileLocation)

append
  attachElement(
    append: location
    getNewElement
      all creation and update logic

@kidonng

kidonng commented Jul 5, 2022 •

Copy link
Copy Markdown
Member Author

If we had something like Preact it’d be presumably easier to handle this sort of content.

Or SolidJS, which uses native DOM that maybe interesting for our use case. (Not trying to stir up another UI library war, just mentioning 😂)

I don't know about the attachElement helper until now, but that will require rewriting most of the logic and make the already ugly diff worse. The feature is already 150+ lines without this PR so I guess we can make do with a little duplicate logic here.

Unless someone find a nice way to avoid duplicating these, I think this PR is done.

const datePromise = getLastCommitDate(login);
const race = await Promise.race([delay(300), datePromise]);
if (race === false) {
// The timezone was undeterminable and this resolved "immediately" (or was cached), so don't add the icon at all
return;
}

@kidonng
kidonng marked this pull request as ready for review July 5, 2022 16:06

@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.

TL;DReview

@kidonng
kidonng merged commit c05bc22 into main Jul 5, 2022
@kidonng
kidonng deleted the user-local-time branch July 5, 2022 16:45
@fregante

fregante commented Jul 6, 2022

Copy link
Copy Markdown
Member

The problem is that we can’t use JSX (due to the issues described in my last attempt PR) and Solid.js has some footguns when used without it: https://www.solidjs.com/guides/getting-started#buildless-options

Preact doesn’t appear to have this issue.

I’m not attached to any library but anything that makes it easy, painfree and is under 5kb would be great.

@fregante

fregante commented Jul 7, 2022

Copy link
Copy Markdown
Member

I think this would be the correct solution: https://lit.dev/

Unlike most other libraries, these elements are regular dom elements that can be created and appended even with our JSX setup because they’re triggered by a basic body.append(document.createElement('rgh-time')) and it automatically detects when the element is removed.

Any custom-element-based library should work though.

@kidonng

kidonng commented Jul 7, 2022 •

Copy link
Copy Markdown
Member Author

Would like to evaluate which features will benefit from using a UI library first.

@fregante

fregante commented Jul 8, 2022

Copy link
Copy Markdown
Member

It’s probably not a whole lot, that’s why library size is important. But if it’s available we’ll surely come up with more. The options page would also definitely benefit from dynamic components, we have a lot of dynamic code in it

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.

Extend user-local-time to user profiles

3 participants