question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a "last unread" indicator for reports

See original GitHub issue

If you haven’t already, check out our contributing guidelines for onboarding!


Platform - version: web, ios, android, desktop - version number Version 1.0.1-444 (1.0.1-444)

Action Performed:

  • Create a group chat in e.cash desktop, web, ios, android
  • Send a message to the group chat
  • Go offline
  • Come back to the chat and look for the last message you read
  • Create a marker for responses to a thread that happened since the last time you read the thread.

image

Expected Result:

  • User should see a new message marker in all chat threads - even non-group chats
  • The new message marker needs to have a height of 0 so it can fit nicely between the chats

Actual Result:

  • At this time, the only method to see the last read message is looking at the time stamp.

  • Currently, the only method to determine the last message you’ve read is by the date of the messages

And some guidelines for a solution in the code:

UnreadActionIndicator

This simple component will render an <Animated.View /> as a horizontally-oriented flexbox containing:

  • A <Text /> component containing the word “new”
  • An empty <View/> with a width but no height, and a green borderBottom (AKA a horizontal rule in React Native).

It should have a very simple animation to fade out when being hidden.

ReportActionsView

We need to make sure that the last unread comment on the report remains unread until the user leaves the report and comes back. We’ll start by writing a new function called recordLastUnreadAction. It will grab the lastUnreadAction from the report. If none is found, we’ll use the highest visible sequence number, just like recordMaxAction does now.

Then we’ll rename recordMaxAction to recordMaxVisibleAction, and replace all uses of recordMaxAction with recordLastUnreadAction, except for this one, which is triggered when an inactive report becomes active again. In that case, we’ll call scrollToAction with the sequence number of the last unread action so that we display the last unread comment in the report, then call recordMaxVisibleAction.

We’ll then create a new function called insertUnreadIndicator, which will inject an object with {type: ‘unreadIndicator’} into the sortedReportAction array in the position immediately following the lastUnreadAction.

Then we’ll update renderItem to check the type of the item, and if it is unreadIndicator, it will render an <UnreadActionIndicator /> instead of a <ReportActionItem />. In markAllRead, we’ll trigger the hide animation on the <UnreadActionIndicator />, then when it’s completed remove it from the sortedReportActions array.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:29 (28 by maintainers)

github_iconTop GitHub Comments

1reaction
lucas-neuhaus-devcommented, Feb 26, 2021

Do we need to “get” the unreadActionCount I think it should just be attached to the report object?

Yeah, but we still have to write a little function to get it, since ONYXKEYS.COLLECTION.REPORT returns an array with all the reports. But the name is because I was actually returning this value from the function, but I am not anymore. I’ll think of something better. Below is how I extracted the unreadActionCount:

this.unreadActionCount = _.find(this.props.reports, report => (
      report.reportID === this.props.reportID
)).unreadActionCount;

I think FlatList having a dynamic height items could also make this difficult to do.

It does. I did some tests and it misses the action index by a decent margin. The other way I can think of achieving this would be something like this. Try to calculate the height of each item on render time, do some calculations and call FlatList.scrollToOffset().

Yes so this is a practice that will end soon since we are switching to react-navigation the initial motivation as I understand it was so that these reports would get “pre-rendered” and make switching between them faster.

I see, thanks for the explanation.

1reaction
shawnbortoncommented, Feb 24, 2021

Awesome, thanks for your feedback though and working through the mockups with me!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create a Notification Bell in Power BI - YouTube
It shows a red circle with a count of the significant events that have occurred since the last time you viewed the report....
Read more >
Is there any way at all to show a badge for unread messages ...
I can get a badge on the taskbar icon, but if I close the window instead of minimizing it, then I don't see...
Read more >
Icons: Unread Notes Indicator - Knowledge Base
The logic on the Long List page for badges (Unread Notes Indicator) compares the last time the note was viewed from the Long...
Read more >
Unread indicators - support - Discourse Meta
By default, topics are considered unread and will show unread counts if you: Created the topic; Replied to the topic; Read the topic...
Read more >
Sometimes the threads unread indicator shows, but I don't ...
Be reading a threads; Notice that the thread unread indicator is showing ... Add thread notification with server assistance (MSC3773) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found