-
-
Notifications
You must be signed in to change notification settings - Fork 592
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
Fix getLatestTimeline
not working when the latest event in the room is a threaded message
#2521
Changes from all commits
5f4d10d
e8dc590
9882eb6
fdeb9e0
78f8019
50b5bb1
a3457e1
cdef5cb
cd41d7e
a3ea213
b97de19
f82ea0c
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ node_modules | |
/*.log | ||
package-lock.json | ||
.lock-wscript | ||
.DS_Store | ||
build/Release | ||
coverage | ||
lib-cov | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5152,15 +5152,15 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa | |
* <p>If the EventTimelineSet object already has the given event in its store, the | ||
* corresponding timeline will be returned. Otherwise, a /context request is | ||
* made, and used to construct an EventTimeline. | ||
* If the event does not belong to this EventTimelineSet then undefined will be returned. | ||
* If the event does not belong to this EventTimelineSet then it will ignored. | ||
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. 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 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. Let's first discuss the previous behavior. Previously, when the event didn't belong to the In our usage, there is only a single spot where the caller uses the It's probably a misnomer to call it And my new With the updates, we're only working within the given Previously, we would return By ignored, I mean if the 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. Our usage might be to be a fire-and-forget pattern (or wrong, in the case of needing to use We can adjust our code to instead use a new 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. The Can we change the experimental implementation?
In any case, this can work 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. 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 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. Conversation continued at #2852 (comment) |
||
* | ||
* @param {EventTimelineSet} timelineSet The timelineSet to look for the event in, must be bound to a room | ||
* @param {string} eventId The ID of the event to look for | ||
* | ||
* @return {Promise} Resolves: | ||
* {@link module:models/event-timeline~EventTimeline} including the given event | ||
*/ | ||
public async getEventTimeline(timelineSet: EventTimelineSet, eventId: string): Promise<Optional<EventTimeline>> { | ||
public async getEventTimeline(timelineSet: EventTimelineSet, eventId: string): Promise<EventTimeline> { | ||
// don't allow any timeline support unless it's been enabled. | ||
if (!this.timelineSupport) { | ||
throw new Error("timeline support is disabled. Set the 'timelineSupport'" + | ||
|
@@ -5210,10 +5210,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa | |
]; | ||
|
||
if (this.supportsExperimentalThreads()) { | ||
if (!timelineSet.canContain(event)) { | ||
return undefined; | ||
} | ||
Comment on lines
-5213
to
-5215
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. Instead of returning Did returning 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.
I don't think it has any special meaning, see #2521 (comment)
Comment on lines
-5213
to
-5215
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. 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. @t3chguy Any hints here? |
||
|
||
// Where the event is a thread reply (not a root) and running in MSC-enabled mode the Thread timeline only | ||
// functions contiguously, so we have to jump through some hoops to get our target event in it. | ||
// XXX: workaround for https://github.com/vector-im/element-meta/issues/150 | ||
|
@@ -5260,9 +5256,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa | |
// There is no guarantee that the event ended up in "timeline" (we might have switched to a neighbouring | ||
// timeline) - so check the room's index again. On the other hand, there's no guarantee the event ended up | ||
// anywhere, if it was later redacted, so we just return the timeline we first thought of. | ||
return timelineSet.getTimelineForEvent(eventId) | ||
?? timelineSet.room.findThreadForEvent(event)?.liveTimeline // for Threads degraded support | ||
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.
What does If 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.
Server has no APIs to help the client so the client has to build the threads objects without filters & relations support on the server based on /sync and /messages data alone, which is a mode we have to continue to support. 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 for the context! I think it's safe to drop this case given |
||
?? timeline; | ||
return timelineSet.getTimelineForEvent(eventId) ?? timeline; | ||
} | ||
|
||
/** | ||
|
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.
This tests the two main mixing scenarios. We could add tests for the other mixing scenarios but we're using
canContain
which already has it's own set of tests,matrix-js-sdk/spec/unit/event-timeline-set.spec.ts
Lines 227 to 293 in 5112340