-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Improve Chat Switch timing in Grafana so it waits for all messages to layout #2684
Changes from 5 commits
99a972b
6ee24bd
ba525f0
2f66572
778400c
4277ea6
72d2a94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,9 @@ const propTypes = { | |
|
||
// Should we display the new indicator on top of the comment? | ||
shouldDisplayNewIndicator: PropTypes.bool.isRequired, | ||
|
||
// Runs when the view enclosing the chat message lays out indicating it has rendered | ||
onLayout: PropTypes.func.isRequired, | ||
}; | ||
|
||
const defaultProps = { | ||
|
@@ -122,7 +125,7 @@ class ReportActionItem extends Component { | |
{this.props.shouldDisplayNewIndicator && ( | ||
<UnreadActionIndicator /> | ||
)} | ||
<View style={getReportActionItemStyle(hovered)}> | ||
<View style={getReportActionItemStyle(hovered)} onLayout={this.props.onLayout}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh nice, didn't know that View has an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://reactnative.dev/docs/view#onlayout The docs do say
I think this is maybe as close as we can get to treating an individual chat message as "rendered". There might be a better indicator to use. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey I thought that as well, I don't mean to get you sidetracked but here's what I've found looking for an alternative: viewabilityConfigCallbackPairs
And in ViewabilityHelper.js
I've never used this but it seems you can configure this and wait for the callback to get called for all the items or just the first 5-10 (Thought what about when there are less than 10...) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Anyway I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, that's interesting! The docs are kind of sparse on that stuff so I'm not too sure if I'll go down this road right now. I think it will maybe be slightly more complicated to use this then to do the naive idea I had. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mostly because |
||
{!this.props.displayAsGroup | ||
? ( | ||
<ReportActionItemSingle action={this.props.action}> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB, but is it true that a slow child component taking longer than the denounce time to render would trigger a false measurement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think if we had a child that takes more than a second to render we'd definitely get a funky measurement.
I think it's pretty unlikely for that to happen.
I came across another issue here though that I'm going to look into addressing now.
If we switch chats before thing are done rendering it's possible to get a negative value recorded so I'll look into how to prevent this before proceeding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok figured that one out and we just need to cancel the debounced method in
componentWillUnmount()
so it does not incorrectly set the timer end when switching to the next chat.So, do you think it's OK to have this... or should we perhaps increase the time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As unlikely as this is, I think it would be better to set a slightly higher debounce time -- just in case. But it's NAB. I'll leave it up to you 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna bump it to 1500