mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 19:56:47 +03:00
Merge pull request #1775 from matrix-org/luke/fix-room-list-reordering-e2e
Reorder the RoomListStore lists on Event.decrypted
This commit is contained in:
commit
a28691b9de
2 changed files with 35 additions and 0 deletions
|
@ -163,6 +163,26 @@ function createRoomMembershipAction(matrixClient, membershipEvent, member, oldMe
|
|||
return { action: 'MatrixActions.RoomMember.membership', member };
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef EventDecryptedAction
|
||||
* @type {Object}
|
||||
* @property {string} action 'MatrixActions.Event.decrypted'.
|
||||
* @property {MatrixEvent} event the matrix event that was decrypted.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a MatrixActions.Event.decrypted action that represents
|
||||
* a MatrixClient `Event.decrypted` matrix event, emitted when a
|
||||
* matrix event is decrypted.
|
||||
*
|
||||
* @param {MatrixClient} matrixClient the matrix client.
|
||||
* @param {MatrixEvent} event the matrix event that was decrypted.
|
||||
* @returns {EventDecryptedAction} an action of type `MatrixActions.Event.decrypted`.
|
||||
*/
|
||||
function createEventDecryptedAction(matrixClient, event) {
|
||||
return { action: 'MatrixActions.Event.decrypted', event };
|
||||
}
|
||||
|
||||
/**
|
||||
* This object is responsible for dispatching actions when certain events are emitted by
|
||||
* the given MatrixClient.
|
||||
|
@ -183,6 +203,7 @@ export default {
|
|||
this._addMatrixClientListener(matrixClient, 'Room.tags', createRoomTagsAction);
|
||||
this._addMatrixClientListener(matrixClient, 'Room.timeline', createRoomTimelineAction);
|
||||
this._addMatrixClientListener(matrixClient, 'RoomMember.membership', createRoomMembershipAction);
|
||||
this._addMatrixClientListener(matrixClient, 'Event.decrypted', createEventDecryptedAction);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -87,6 +87,20 @@ class RoomListStore extends Store {
|
|||
this._generateRoomLists();
|
||||
}
|
||||
break;
|
||||
// When an event is decrypted, it could mean we need to reorder the room
|
||||
// list because we now know the type of the event.
|
||||
case 'MatrixActions.Event.decrypted': {
|
||||
const room = this._matrixClient.getRoom(payload.event.getRoomId());
|
||||
const liveTimeline = room.getLiveTimeline();
|
||||
const eventTimeline = room.getTimelineForEvent(payload.event.getId());
|
||||
|
||||
if (!this._state.ready ||
|
||||
liveTimeline !== eventTimeline ||
|
||||
!this._eventTriggersRecentReorder(payload.event)
|
||||
) break;
|
||||
this._generateRoomLists();
|
||||
}
|
||||
break;
|
||||
case 'MatrixActions.accountData': {
|
||||
if (payload.event_type !== 'm.direct') break;
|
||||
this._generateRoomLists();
|
||||
|
|
Loading…
Reference in a new issue