Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sticky date markers #2731

Open
wants to merge 48 commits into
base: develop
Choose a base branch
from
Open

Conversation

holmesworcester
Copy link
Contributor

This addresses #505 to show sticky, floating date markers.

Pull Request Checklist

  • I have linked this PR to a related GitHub issue.
  • I have added a description of the change (and Github issue number, if any) to the root CHANGELOG.md.

@holmesworcester holmesworcester changed the title Feature/sticky date markers (WIP) Add sticky date markers (WIP) Feb 6, 2025
@holmesworcester holmesworcester changed the title Add sticky date markers (WIP) Add sticky date markers Feb 12, 2025
@holmesworcester holmesworcester force-pushed the feature/sticky-date-markers branch from 7816bc1 to 1a399db Compare February 12, 2025 18:03
@adrastaea adrastaea self-requested a review February 12, 2025 20:44
@adrastaea
Copy link
Collaborator

Screenshot 2025-02-12 at 3 34 25 PM
One style nitpick, after scrolling all the way up, the floating date marker does not line up with the static date marker which looks a little janky until the floating marker disappears. I think that aligning the margins would make it look more seamless

cy.get(floatingDateSelector)
.should('be.visible')
.invoke('text')
.should('contain', '28 Oct')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a way we can avoid hardcoding this, and derive the expected value from the test data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's an easy solution to this, but doing so makes me a bit uncomfortable, since if we derive the date format we might introduce a bug that changes the formatter in both production and in the test. Also, hardcoded test data makes it very clear to anyone looking at this what date format is expected.

(There's another issue with this test where the test should be "equals" and not "contains" (since if the date also displayed the year, incorrectly, this test would still pass). I fixed that in the other PR I'm working on for making dates match the design.)

Are you okay with leaving it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm okay with leaving it. I see your point of making it obvious to anyone reading the test what the value should be, which is more obvious with the string than with a const.

})}
pendingGeneralChannelRecreation={false}
removeFile={dummyRemoveFile}
{...args}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you're using the spread operator correctly here. I think you're trying to use the args partial you defined earlier, but you've ended up needing to hardcode a lot of the values included in that partial because you have put them next to args like

{...args}
otherVal='otherVal'

instead of using your hardcoded values to add new keys or replace keys in args like

{
    ...args,
    otherVal: 'otherVal'
}

I think this would work better if you used the Template pattern used by the other stories.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the reason we can't use the Template pattern here is because in this story for the interactivity we need component state (UseState) but Args in Storybook are static. (I don't totally understand this stuff yet.)

groups: { [day: string]: DisplayableMessage[][] }
}>(mock_messages())

const handleSend = (message: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The new message isn't ordered properly when sent in this interactive story. Also, I don't have a real Quiet instance with old messages, but in this interactive UI, scrolling above the top briefly shifts the floating date marker from Oct 26 to Today

Screen.Recording.2025-02-12.at.6.51.52.PM.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed ordering! I saw that and was being lazy because it didn't really affect what I was testing, but it's weird and definitely good to fix.

On the "Today" flashing on transitions, I was not able to reproduce what you were seeing in Storybook, so I assume the issue was happening in the app too and I just wasn't seeing it there either. I found what I think was the culprit and fixed it. Let me know if you still see it!

)
}

export { FETCHING_MESSAGES as fetchingChannelMessagesText, DELETING_CHANNEL as deletingChannelMessage }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Renaming constants in order to export them feels like an anti-pattern. We should just commit to renaming them with the all caps pattern everywhere. If you use F2 to rename a variable in your IDE, it should rename it everywhere automatically, so you don't have to do hacks like this to fix import problems.

@@ -272,7 +272,7 @@ describe('publicChannelsSelectors', () => {

// Get groups names
const groupDay1 = formatMessageDisplayDay(formatMessageDisplayDate(msgs['7'].createdAt))
expect(groupDay1).toBe('Feb 05')
expect(groupDay1).toBe('Feb 5')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another place we could be using references to the test data instead of hardcoding

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is easy to fix but I have the same question/doubt as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants