Update the live timeline when the JS SDK resets it (#8806)
This commit is contained in:
parent
1b7e9d95da
commit
53340db5e9
3 changed files with 75 additions and 50 deletions
|
@ -30,6 +30,7 @@ import { logger } from "matrix-js-sdk/src/logger";
|
|||
import { EventTimeline } from 'matrix-js-sdk/src/models/event-timeline';
|
||||
import { EventType } from 'matrix-js-sdk/src/@types/event';
|
||||
import { RoomState, RoomStateEvent } from 'matrix-js-sdk/src/models/room-state';
|
||||
import { EventTimelineSet } from "matrix-js-sdk/src/models/event-timeline-set";
|
||||
import { CallState, CallType, MatrixCall } from "matrix-js-sdk/src/webrtc/call";
|
||||
import { throttle } from "lodash";
|
||||
import { MatrixError } from 'matrix-js-sdk/src/http-api';
|
||||
|
@ -282,6 +283,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
|||
this.dispatcherRef = dis.register(this.onAction);
|
||||
context.on(ClientEvent.Room, this.onRoom);
|
||||
context.on(RoomEvent.Timeline, this.onRoomTimeline);
|
||||
context.on(RoomEvent.TimelineReset, this.onRoomTimelineReset);
|
||||
context.on(RoomEvent.Name, this.onRoomName);
|
||||
context.on(RoomStateEvent.Events, this.onRoomStateEvents);
|
||||
context.on(RoomStateEvent.Update, this.onRoomStateUpdate);
|
||||
|
@ -1022,6 +1024,12 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
|||
});
|
||||
};
|
||||
|
||||
private onRoomTimelineReset = (room: Room, timelineSet: EventTimelineSet) => {
|
||||
if (!room || room.roomId !== this.state.room?.roomId) return;
|
||||
logger.log(`Live timeline of ${room.roomId} was reset`);
|
||||
this.setState({ liveTimeline: timelineSet.getLiveTimeline() });
|
||||
};
|
||||
|
||||
private getRoomTombstone(room = this.state.room) {
|
||||
return room?.currentState.getStateEvents(EventType.RoomTombstone, "");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue