-
-
Notifications
You must be signed in to change notification settings - Fork 672
Fix getLatestTimeline not working when the latest event in the room is a threaded message
#2521
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
Closed
MadLittleMods
wants to merge
12
commits into
develop
from
madlittlemods/refresh-timeline-when-we-see-msc2716-marker-events-v2
Closed
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5f4d10d
Fix getLatestTimeline not working when the latest even in the room wa…
MadLittleMods e8dc590
Adjust tests to not include problem events instead of undefined timeline
MadLittleMods 9882eb6
Add tests for not being able to add mixed events
MadLittleMods fdeb9e0
Correct JSDoc and types for getEventTimeline
MadLittleMods 78f8019
No longer need check since it should always return a timeline
MadLittleMods 50b5bb1
Add getLatestTimeline test for latest event being thread
MadLittleMods a3457e1
Add non-optional client to Room instances
MadLittleMods cdef5cb
Fix lint
MadLittleMods cd41d7e
We expect void so return void
MadLittleMods a3ea213
Merge branch 'develop' into madlittlemods/refresh-timeline-when-we-se…
MadLittleMods b97de19
Merge branch 'develop' into madlittlemods/refresh-timeline-when-we-se…
MadLittleMods f82ea0c
Fix some lints
MadLittleMods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Correct JSDoc and types for getEventTimeline
- Loading branch information
commit fdeb9e0df751efda307e92990e0364a75c720e7c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The event will be ignored? What does that even mean? This method isn't meant to process the given event, just use it as a pointer. What event timeline will be returned to the caller? The caller would now have need to manually check that the returned timeline is valid for what they asked for, I guess by your other change lower down by attempting to add an event and by asserting that it worked, that seems rather strange
Uh oh!
There was an error while loading. Please reload this page.
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.
Let's first discuss the previous behavior. Previously, when the event didn't belong to the
timelineSet, we would returnundefinedand create no additional timelines. Returningundefinedhas no special meaning given that all of the usage is always fire and forget meaning we don't use thetimelinereturned byclient.getEventTimeline()and only use the function to load the event so it's available to the client.In our usage, there is only a single spot where the caller uses the
timelinereturned byclient.getEventTimeline(). This usage should be replaced by the fire and forget pattern and useroom.findEventById(eventId)because it doesn't even use thetimeline, it just wants the event that was loaded in as well.It's probably a misnomer to call it
getEventTimeline(): timelinein the first place as it's more accurately used asloadEventInTimeline(): Promise<void>everywhere.And my new
refreshLiveTimelineandgetLatestTimelineusage is the only one where it needs an actually timeline.With the updates, we're only working within the given
timelineSetthat was passed in (seems reasonable). Ifclient.getEventTimeline()is really meant to just give the timeline for theeventId, then we should just provide theroominstead which can look at all of the timelineSets (room.timelineSets).Previously, we would return
undefinedin the case where the event doesn't belong in thetimelineSet. Now we're returning atimelinein thetimelineSetwhere all of the events returned by/contextcan go. This means events that we fetched, are actually added and not wasted. And it means that the main room timeline can be populated regardless if theeventIdpassed in was a threaded reply.By ignored, I mean if the
eventIdis a threaded reply, it won't be added to the main roomtimelineSetthat was passed in for example.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.
Our usage might be to be a fire-and-forget pattern (or wrong, in the case of needing to use
findEventByIdinstead), but as a public function and SDK we have to maintain a rationalized contract for the function name: it says it gets an event timeline, so it should do that (returningundefinedif needed)We can adjust our code to instead use a new
updateEventTimeline()function or similar, but the existinggetEventTimelinefunction can't realistically have a behavioural change like this.Uh oh!
There was an error while loading. Please reload this page.
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.
The
return undefinedpart is part ofsupportsExperimentalThreadswhich changed in https://github.com/matrix-org/matrix-js-sdk/pull/2444/filesCan we change the experimental implementation?
In any case, this can work
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.
I'm still not comfortable with the behavioural change here, sorry. While our usage might be fire-and-forget, we can't guarantee that all usages of the function are fire-and-forget. The documentation and function itself are not experimental in nature as well, preventing us from making arbitrary breaking changes.
Adding a function is more code, but I think it's worthwhile here. It can even call
getEventTimeline()and ignore the return value - it looks a bit silly, but it's how we avoid unnecessary major version releases.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.
Conversation continued at #2852 (comment)