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

Implement ReportDateIndicator #35897

Closed
wants to merge 25 commits into from

Conversation

MrRefactor
Copy link
Contributor

@MrRefactor MrRefactor commented Feb 6, 2024

Details

This PR concentrates on implementing Date dividers within chats to distinguish Today, Yesterday and other dates. We add an indicator between each day of the week that changes between messages, giving indication when that message was sent in an easy way.

Fixed Issues

$ #18101
PROPOSAL: #18101 (comment)

Tests

  1. Open chat,
  2. Check if the "moving" indicator is showing correct date,
  3. Scroll the chat up and down between dates to check if "moving" indicator is correctly switching dates,
  4. Verify that "static" indicators are showing correct dates
  • Verify that no errors appear in the JS console

Offline tests

Same as tests

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android-native.mov
Android: mWeb Chrome
android-web.mov
iOS: Native
ios.mov
iOS: mWeb Safari
ios-web.mov
MacOS: Chrome / Safari
web-chrome.mov
safari-web.mov
MacOS: Desktop
desktop.mov

src/libs/DateUtils.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@rezkiy37 rezkiy37 left a comment

Choose a reason for hiding this comment

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

Left comments, after LGTM.

src/libs/DateUtils.ts Outdated Show resolved Hide resolved
src/libs/DateUtils.ts Outdated Show resolved Hide resolved
src/libs/DateUtils.ts Outdated Show resolved Hide resolved
@MrRefactor MrRefactor marked this pull request as ready for review February 28, 2024 12:19
@MrRefactor MrRefactor requested a review from a team as a code owner February 28, 2024 12:19
@melvin-bot melvin-bot bot requested review from chiragsalian and removed request for a team February 28, 2024 12:19
Copy link

melvin-bot bot commented Feb 28, 2024

@chiragsalian Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@shawnborton
Copy link
Contributor

cc @Expensify/design for a review on this one

I wonder if we should add like 4px of vertical padding to the rows that contain the dates? This way we don't get the row:hover effect from chat messages bumping right up against it like this:
CleanShot 2024-02-28 at 08 45 19@2x

Notice that Slack has something similar going on:
CleanShot 2024-02-28 at 08 45 59@2x

@shawnborton
Copy link
Contributor

And maybe in doing that, the top-anchored badge will be just slightly further away from the top header bar - I think a little extra padding/gap would be nice:
CleanShot 2024-02-28 at 08 46 43@2x

@shawnborton
Copy link
Contributor

Do you have an example to show with the new message indicator (green button)?

@MrRefactor
Copy link
Contributor Author

Do you have an example to show with the new message indicator (green button)?

here you go!

Screen.Recording.2024-02-28.at.21.54.06.mov

@dannymcclain
Copy link
Contributor

The new message indicator is looking good!

@shawnborton I agree the date badges need some space. In my mocks I have 8px of top and bottom padding around them. From the video @MrRefactor posted, it looks like the new message indicator also sits 8px away from the top.

CleanShot 2024-02-28 at 07 59 10

@MrRefactor
Copy link
Contributor Author

The new message indicator is looking good!

@shawnborton I agree the date badges need some space. In my mocks I have 8px of top and bottom padding around them. From the video @MrRefactor posted, it looks like the new message indicator also sits 8px away from the top.

My bad, I will apply the changes soon!

@MrRefactor
Copy link
Contributor Author

@shawnborton Pushed changes containing padding fix!

@shawnborton
Copy link
Contributor

Wonderful, do you have new screenshots for review?

@shawnborton
Copy link
Contributor

Also, going to run a quick test build so we can test as well.

@MrRefactor
Copy link
Contributor Author

Also, going to run a quick test build so we can test as well.

Screenshot 2024-02-28 at 22 42 26
Screenshot 2024-02-28 at 22 42 19

This comment has been minimized.

@shawnborton
Copy link
Contributor

Going to leave some comments now that I am testing!

For this case:
CleanShot 2024-02-28 at 10 18 24

I would think that the Feb 6 date badge would be on top of the Feb 2 badge as we scroll. I also think the Feb 2 badge should stop scrolling with the message a bit sooner - it doesn't need to keep scrolling with the page even if the Feb 2 message is aleady gone. Let me know if that makes sense.

@shawnborton
Copy link
Contributor

Found a case of the same date being duplicated:
CleanShot 2024-02-28 at 10 20 19@2x

@MrMuzyk
Copy link
Contributor

MrMuzyk commented Apr 30, 2024

I've found issue with Today indicator - it wasn't showing up instantly when writing new messages (it was there after refresh/switching chats). This is probably the issue you've encountered.

I've fixed that so it should always instantly popup when typing first message of the day

today_indicator_fix.mp4

I'm seeing Yesterday (or another date) repeated multiple times.

This is something that I wasn't able to reproduce. I've checked it in multiple conversations and everything was fine. Can you provide some reproduction steps?

@shawnborton
Copy link
Contributor

This is something that will be done in a followup PR in the future, is that correct?

I think that was the idea but after seeing it in action, it makes me wonder if we should try to implement it correctly the first time, otherwise we're going to be in a weird state without the floating labels for a while. Do we have any idea how long a follow up would take, and what the technical feasibility is like? Just want to make sure we have a solid plan and that we aren't just kicking this can down the road.

@shawnborton
Copy link
Contributor

Also, I think we really need to sort out our approach for threads and reports. Do you have thoughts there @puneetlath?

For example, it doesn't feel super great here:
CleanShot 2024-04-30 at 08 31 57@2x

Not to mention that report should actually display as a single transaction view, so maybe you need to pull in main?

@MrMuzyk
Copy link
Contributor

MrMuzyk commented Apr 30, 2024

Do we have any idea how long a follow up would take, and what the technical feasibility is like?

I will investigate this and I will try to get back to you with an answer today but no promises as I will be finishing for the day soon (I will be back 6th of May)

Not to mention that report should actually display as a single transaction view, so maybe you need to pull in main?

Recording was done after merging main today in the morning and I'm pretty sure changes from this branch didn't add/change anything else but the indicator. I will rebase again

@shawnborton
Copy link
Contributor

Sounds good, will trigger a new test build

@MrMuzyk
Copy link
Contributor

MrMuzyk commented Apr 30, 2024

This was @MrRefactor idea for the implementation of the floating indicator. I will discuss this with him, maybe search for some kind of alternative as he mentioned costly refactor and get back with an estimate

Copy link
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪

Android 🤖 iOS 🍎
https://ad-hoc-expensify-cash.s3.amazonaws.com/android/35897/index.html https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/35897/index.html
Android iOS
Desktop 💻 Web 🕸️
❌ FAILED ❌ https://35897.pr-testing.expensify.com
The QR code can't be generated, because the Desktop build failed Web

👀 View the workflow run that generated this build 👀

@shawnborton
Copy link
Contributor

Seeing some weirdness with timezones maybe?

This PR:
CleanShot 2024-04-30 at 10 57 48@2x

Staging:
CleanShot 2024-04-30 at 10 58 19@2x

@shawnborton
Copy link
Contributor

Labels don't show up in the one-expense view of a report:
CleanShot 2024-04-30 at 10 59 08@2x

@shawnborton
Copy link
Contributor

I'm still not seeing a "Today" label in the #social room either.

@puneetlath
Copy link
Contributor

So am I right in understanding:

  1. We still think the ReportDateIndicator is better than how we currently do dates in the timestamp
  2. We want to use it everywhere -- threads, transactions, etc
  3. We only want to use it if we can do the "flowing" indicator, as the fixed position one is not good enough

Is that right? If so, maybe we assess the technical complexity of doing the flowing indicator. And based on that we decide whether we want to go forward or just punt this for now.

@shawnborton
Copy link
Contributor

That sounds about right, though I am a bit torn on this point:

We want to use it everywhere -- threads, transactions, etc

It can definitely make the threads a little messy, especially if you are nested a few levels deep across a range of dates/times in a thread. What do you think we should do there?

@puneetlath
Copy link
Contributor

I agree with you that it looks a little weird. But I also don't love the idea of using different styles in different rooms. Which is why I'm kind of questioning the feature altogether 😅

@shawnborton
Copy link
Contributor

Haha yeah, I think we'd want to see these floating labels in those places to better make our decision. @MrMuzyk can you see if you can get the pill labels to show up in places like threads as well?

@dannymcclain
Copy link
Contributor

We still think the ReportDateIndicator is better than how we currently do dates in the timestamp

Yeah right now I'm not totally sold that this is better than how we're currently doing it.

@MrMuzyk
Copy link
Contributor

MrMuzyk commented May 7, 2024

Seeing some weirdness with timezones maybe?

I can look into this


Labels don't show up in the one-expense view of a report:

can you see if you can get the pill labels to show up in places like threads as well?

This is weird because they are showing up for me when I'm running this locally. Screenshots below

Screenshot 2024-05-07 at 12 23 21 Screenshot 2024-05-07 at 12 23 36 image

I'm still not seeing a "Today" label in the #social room either.

Screenshot 2024-05-07 at 12 26 28

Same case as above. It is working fine for me 🤔


@puneetlath @shawnborton

When it comes to implementing floating indicators I've had a chat with @MrRefactor today and we both do not see the way of implementing indicators in the same manner as slack does in the current state of the app. The part where new indicator pushes the old one is the most complex bit that we don't know how to tackle. We both think that having opinion from someone who is more experienced with animations might be helpful - @WoLewicki

@WoLewicki
Copy link
Contributor

Hey, is there a reason why I have been mentioned here?

@MrMuzyk
Copy link
Contributor

MrMuzyk commented May 7, 2024

@WoLewicki Hey, @MrRefactor was working on a feature introducing date indicators and now I'm helping him with this as he's busy with RN upgrade. Some time ago there was a sugestion to create this in the same manner as slack is handling this. We have a v1 that is different but we want to estimate and plan how much work would it be to make it work and look like in the slack example. As I've mentioned in the previous comment we've had a chat today with @MrRefactor regarding this and we couldn't see a clear plan on how to achieve the same effect as in slack app. He suggested that it would be great to get your opinion on this feature. Do you think it is achievable in the current state of the app?

@WoLewicki
Copy link
Contributor

Hey! I am no expert in this manner unfortunately 😅 I guess you could probably implement it as sticky headers? I can see there is an issue in FlashList repo regarding having it in inverted mode: Shopify/flash-list#611. Did you investigate this approach at all?

Another approach with the current implementation would be to pass information about the current scroll offset and mimic the behavior of sticky headers the core (https://github.com/facebook/react-native/blob/cc99e924ca4f8d29cb6bf6bb5d2e180df541936a/packages/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js).

Do you think it is achievable in the current state of the app?

I think there are no hard limitations that could prevent us from doing it.

@MrMuzyk
Copy link
Contributor

MrMuzyk commented May 10, 2024

Thanks for the input 👍

So the option with sticky headers was investigated but we can't go this path because of 2 reasons:

  1. Like you've mentioned the inverted sticky header doesn't work properly at the moment
  2. We're not even sure if it would do the trick in our case. It could work when scrolling down for sure but we're not 100% convinced if it would work as well when scrolling up. We can't even test it now because inverted sticky header isn't working 😞 We could prepare some kind of mvp on regular list and see if it would work.

Custom solution might be the way to go if we want to implement it in the near future.

It would also be great to have full requirements on how the date dividers should behave in multiple scenarios. I know that we have this gif showcasing how it works on slack but having a bit more than that would also help us decide on the possible approach in the future.

@puneetlath @shawnborton
Can you check if the current version still misbehaves for you? If so, can you please provide some videos/screenshots and steps to reproduce your issues? In this comment I've provided some screenshots showcasing that it works fine for me in multiple scenarios. On top of that I've fixed the issue with timezones that was pointed out :)

@puneetlath
Copy link
Contributor

My take is that given the complexity of trying to make the floating headers, we should just set this project aside for now. We have other more pressing concerns (e.g. performance) that I think we're better of focusing on. What do y'all think?

@dannymcclain
Copy link
Contributor

@puneetlath I agree. I feel like the date headers don't work unless they're floating, and given what else is on our plate right now, it doesn't make a whole lot of sense to me to invest heavily in figuring that out.

@shawnborton
Copy link
Contributor

Yup, that makes sense and I agree with that.

@puneetlath
Copy link
Contributor

Ok thanks for your effort on this everyone! Closing out for now.

@puneetlath puneetlath closed this May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants