diff --git a/src/domain/session/SessionViewModel.js b/src/domain/session/SessionViewModel.js index 6f2c9797..7a84e67b 100644 --- a/src/domain/session/SessionViewModel.js +++ b/src/domain/session/SessionViewModel.js @@ -153,10 +153,7 @@ export class SessionViewModel extends ViewModel { _createRoomViewModel(roomId) { const room = this._sessionContainer.session.rooms.get(roomId); if (room) { - const roomVM = new RoomViewModel(this.childOptions({ - room, - ownUserId: this._sessionContainer.session.user.id, - })); + const roomVM = new RoomViewModel(this.childOptions({room})); roomVM.load(); return roomVM; } @@ -173,10 +170,7 @@ export class SessionViewModel extends ViewModel { async _createArchivedRoomViewModel(roomId) { const room = await this._sessionContainer.session.loadArchivedRoom(roomId); if (room) { - const roomVM = new RoomViewModel(this.childOptions({ - room, - ownUserId: this._sessionContainer.session.user.id, - })); + const roomVM = new RoomViewModel(this.childOptions({room})); roomVM.load(); return roomVM; } diff --git a/src/domain/session/room/RoomViewModel.js b/src/domain/session/room/RoomViewModel.js index 5d08f903..d2d46c32 100644 --- a/src/domain/session/room/RoomViewModel.js +++ b/src/domain/session/room/RoomViewModel.js @@ -22,9 +22,8 @@ import {ViewModel} from "../../ViewModel.js"; export class RoomViewModel extends ViewModel { constructor(options) { super(options); - const {room, ownUserId} = options; + const {room} = options; this._room = room; - this._ownUserId = ownUserId; this._timelineVM = null; this._onRoomChange = this._onRoomChange.bind(this); this._timelineError = null; @@ -46,7 +45,6 @@ export class RoomViewModel extends ViewModel { const timelineVM = this.track(new TimelineViewModel(this.childOptions({ room: this._room, timeline, - ownUserId: this._ownUserId, }))); this._timelineVM = timelineVM; this.emitChange("timelineViewModel"); diff --git a/src/domain/session/room/timeline/TimelineViewModel.js b/src/domain/session/room/timeline/TimelineViewModel.js index 04ae7570..63791fa3 100644 --- a/src/domain/session/room/timeline/TimelineViewModel.js +++ b/src/domain/session/room/timeline/TimelineViewModel.js @@ -38,9 +38,9 @@ import {ViewModel} from "../../../ViewModel.js"; export class TimelineViewModel extends ViewModel { constructor(options) { super(options); - const {room, timeline, ownUserId} = options; + const {room, timeline} = options; this._timeline = this.track(timeline); - this._tiles = new TilesCollection(timeline.entries, tilesCreator(this.childOptions({room, timeline, ownUserId}))); + this._tiles = new TilesCollection(timeline.entries, tilesCreator(this.childOptions({room, timeline}))); } /** diff --git a/src/domain/session/room/timeline/tiles/BaseMessageTile.js b/src/domain/session/room/timeline/tiles/BaseMessageTile.js index 8badc429..320aa833 100644 --- a/src/domain/session/room/timeline/tiles/BaseMessageTile.js +++ b/src/domain/session/room/timeline/tiles/BaseMessageTile.js @@ -20,7 +20,7 @@ import {getIdentifierColorNumber, avatarInitials, getAvatarHttpUrl} from "../../ export class BaseMessageTile extends SimpleTile { constructor(options) { super(options); - this._isOwn = this._entry.sender === options.ownUserId; + this._isOwn = this._entry.sender === options.timeline.me.userId; this._date = this._entry.timestamp ? new Date(this._entry.timestamp) : null; this._isContinuation = false; } diff --git a/src/matrix/room/timeline/Timeline.js b/src/matrix/room/timeline/Timeline.js index ce34bbf8..5a72750f 100644 --- a/src/matrix/room/timeline/Timeline.js +++ b/src/matrix/room/timeline/Timeline.js @@ -228,4 +228,8 @@ export class Timeline { get powerLevels() { return this._powerLevels; } + + get me() { + return this._ownMember; + } }