Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

SSC: Fix invite date formatting#62858

Merged
vdavid merged 5 commits into
mainfrom
dv/ssc-invite-date-format
May 23, 2024
Merged

SSC: Fix invite date formatting#62858
vdavid merged 5 commits into
mainfrom
dv/ssc-invite-date-format

Conversation

@vdavid

@vdavid vdavid commented May 22, 2024

Copy link
Copy Markdown
Contributor

This is a step toward https://github.com/sourcegraph/self-serve-cody/issues/725

The list of invitations used to look like this:

CleanShot 2024-05-22 at 17 16 15@2x

Now it looks like this:

CleanShot 2024-05-22 at 17 17 19@2x

which intends to match this design.

Some other examples with the current solution are:

  • Invite sent 5 seconds ago
  • Invite sent 1 hour ago
  • Invite sent yesterday
  • Invite sent last week
    @rrhyne, is this format fine?

Test plan

  • Added tests
  • Tested it manually, it renders well.

@vdavid vdavid requested review from a team and rrhyne May 22, 2024 15:25
@cla-bot cla-bot Bot added the cla-signed label May 22, 2024

@chrsmith chrsmith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR looks great, and I am happy to see you added unit tests for the new functionality.

I'm just blocking the approval because of that excessively complicated one-liner. If we need to have a larger conversation about how many language features in a single line of code is too many, we can have that. But in short, we should optimize for making our code easier to understand and maintain. Getting fancy with syntax or language features is counter to that goal. And even if there were efficiency gains to be made in that style, I'd still maintain that the increased complexity and cost of maintenance is not worth it.

Comment thread client/web/src/cody/team/TeamMemberList.test.ts Outdated
Comment thread client/web/src/cody/team/TeamMemberList.test.ts Outdated
Comment thread client/web/src/cody/team/TeamMemberList.test.ts Outdated
Comment thread client/web/src/cody/team/TeamMemberList.test.ts Outdated
Comment thread client/web/src/cody/team/TeamMemberList.tsx Outdated
@vdavid vdavid enabled auto-merge (squash) May 23, 2024 15:09

@rrhyne rrhyne left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@chrsmith chrsmith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for making the suggested changes. 🙏

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we already have the if (sentAt) the TypeScript compiler knows that the value is truth, and won't give us grief that the type could be null right?

So can't we just write this as:

Suggested change
return intlFormatDistance(sentAt || '', now ?? new Date())
return intlFormatDistance(sentAt, now ?? new Date())

@vdavid vdavid force-pushed the dv/ssc-invite-date-format branch from ca2fd91 to 66e371b Compare May 23, 2024 19:03
@vdavid vdavid merged commit 86bfb30 into main May 23, 2024
@vdavid vdavid deleted the dv/ssc-invite-date-format branch May 23, 2024 19:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants