From 7e177f69530295da923a409357bb86c93ec478f4 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Wed, 18 Aug 2021 17:43:40 +0530 Subject: [PATCH 1/6] Modify open-room action to fix bug Signed-off-by: RMidhunSuresh --- src/domain/navigation/index.js | 13 ++++++++----- .../session/rightpanel/MemberTileViewModel.js | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/domain/navigation/index.js b/src/domain/navigation/index.js index dbac16ac..cf6e1d6f 100644 --- a/src/domain/navigation/index.js +++ b/src/domain/navigation/index.js @@ -132,11 +132,14 @@ export function parseUrlPath(urlPath, currentNavPath, defaultSessionId) { segments.push(roomsSegmentWithRoom(rooms, roomId, currentNavPath)); } segments.push(new Segment("room", roomId)); - // Add right-panel segments from previous path - const previousSegments = currentNavPath.segments; - const i = previousSegments.findIndex(s => s.type === "right-panel"); - if (i !== -1) { - segments.push(...previousSegments.slice(i)); + if (!urlPath.includes("/member/")) { + // Add right-panel segments from previous path if /member is not in url + // fixes memberlist -> member details closing/opening grid view + const previousSegments = currentNavPath.segments; + const i = previousSegments.findIndex(s => s.type === "right-panel"); + if (i !== -1) { + segments.push(...previousSegments.slice(i)); + } } } else if (type === "last-session") { let sessionSegment = currentNavPath.get("session"); diff --git a/src/domain/session/rightpanel/MemberTileViewModel.js b/src/domain/session/rightpanel/MemberTileViewModel.js index 91a07f0c..eac6a6d4 100644 --- a/src/domain/session/rightpanel/MemberTileViewModel.js +++ b/src/domain/session/rightpanel/MemberTileViewModel.js @@ -47,7 +47,8 @@ export class MemberTileViewModel extends ViewModel { } get detailsUrl() { - return `${this.urlCreator.urlUntilSegment("room")}/member/${this._member.userId}`; + const roomId = this.navigation.path.get("room").value; + return `${this.urlCreator.openRoomActionUrl(roomId)}/member/${this._member.userId}`; } _updatePreviousName(newName) { From 2ceaebbd1f2572c241e8e49e47d864d4adc54c52 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Wed, 18 Aug 2021 18:17:37 +0530 Subject: [PATCH 2/6] Don't find roomId in getter Signed-off-by: RMidhunSuresh --- src/domain/session/rightpanel/MemberListViewModel.js | 3 ++- src/domain/session/rightpanel/MemberTileViewModel.js | 4 ++-- src/domain/session/rightpanel/RightPanelViewModel.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/domain/session/rightpanel/MemberListViewModel.js b/src/domain/session/rightpanel/MemberListViewModel.js index 5b8bb83e..664507ff 100644 --- a/src/domain/session/rightpanel/MemberListViewModel.js +++ b/src/domain/session/rightpanel/MemberListViewModel.js @@ -23,6 +23,7 @@ export class MemberListViewModel extends ViewModel { constructor(options) { super(options); const list = options.members; + this._roomId = options.roomId; const powerLevelsObservable = options.powerLevelsObservable; this.track(powerLevelsObservable.subscribe(() => { /*resort based on new power levels here*/ })); @@ -43,7 +44,7 @@ export class MemberListViewModel extends ViewModel { _mapTileViewModels(members) { const mapper = (member, emitChange) => { const mediaRepository = this.mediaRepository; - const vm = new MemberTileViewModel(this.childOptions({member, emitChange, mediaRepository})); + const vm = new MemberTileViewModel(this.childOptions({member, emitChange, mediaRepository, roomId: this._roomId})); this.nameDisambiguator.disambiguate(vm); return vm; } diff --git a/src/domain/session/rightpanel/MemberTileViewModel.js b/src/domain/session/rightpanel/MemberTileViewModel.js index eac6a6d4..c9e460b2 100644 --- a/src/domain/session/rightpanel/MemberTileViewModel.js +++ b/src/domain/session/rightpanel/MemberTileViewModel.js @@ -24,6 +24,7 @@ export class MemberTileViewModel extends ViewModel { this._mediaRepository = options.mediaRepository this._previousName = null; this._nameChanged = true; + this._roomId = options.roomId; } get name() { @@ -47,8 +48,7 @@ export class MemberTileViewModel extends ViewModel { } get detailsUrl() { - const roomId = this.navigation.path.get("room").value; - return `${this.urlCreator.openRoomActionUrl(roomId)}/member/${this._member.userId}`; + return `${this.urlCreator.openRoomActionUrl(this._roomId)}/member/${this._member.userId}`; } _updatePreviousName(newName) { diff --git a/src/domain/session/rightpanel/RightPanelViewModel.js b/src/domain/session/rightpanel/RightPanelViewModel.js index 670df868..c66f1755 100644 --- a/src/domain/session/rightpanel/RightPanelViewModel.js +++ b/src/domain/session/rightpanel/RightPanelViewModel.js @@ -36,7 +36,7 @@ export class RightPanelViewModel extends ViewModel { } const room = this._room; const powerLevelsObservable = await this._room.observePowerLevels(); - return {members: this._members, powerLevelsObservable, mediaRepository: room.mediaRepository}; + return {members: this._members, powerLevelsObservable, mediaRepository: room.mediaRepository, roomId: this._room.id}; } async _getMemberDetailsArguments() { From f841efeef41df77013ed0bf026a613fba0db238b Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 6 Sep 2021 12:41:17 +0530 Subject: [PATCH 3/6] Make check more generic Signed-off-by: RMidhunSuresh --- src/domain/navigation/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/domain/navigation/index.js b/src/domain/navigation/index.js index cf6e1d6f..821121b3 100644 --- a/src/domain/navigation/index.js +++ b/src/domain/navigation/index.js @@ -132,8 +132,10 @@ export function parseUrlPath(urlPath, currentNavPath, defaultSessionId) { segments.push(roomsSegmentWithRoom(rooms, roomId, currentNavPath)); } segments.push(new Segment("room", roomId)); - if (!urlPath.includes("/member/")) { - // Add right-panel segments from previous path if /member is not in url + const partIndex = parts.findIndex(part => part === "open-room"); + const partsAfterRoom = parts.slice(partIndex + 1); + if (partsAfterRoom.length === 1) { + // Copy right-panel segments from previous path only if there are no other parts after open-room // fixes memberlist -> member details closing/opening grid view const previousSegments = currentNavPath.segments; const i = previousSegments.findIndex(s => s.type === "right-panel"); From a54413625e0ac05554214dff6820c783c8ca1795 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 6 Sep 2021 12:59:30 +0530 Subject: [PATCH 4/6] No need to pass in roomId Signed-off-by: RMidhunSuresh --- src/domain/session/rightpanel/MemberListViewModel.js | 3 +-- src/domain/session/rightpanel/MemberTileViewModel.js | 4 ++-- src/domain/session/rightpanel/RightPanelViewModel.js | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/domain/session/rightpanel/MemberListViewModel.js b/src/domain/session/rightpanel/MemberListViewModel.js index 664507ff..5b8bb83e 100644 --- a/src/domain/session/rightpanel/MemberListViewModel.js +++ b/src/domain/session/rightpanel/MemberListViewModel.js @@ -23,7 +23,6 @@ export class MemberListViewModel extends ViewModel { constructor(options) { super(options); const list = options.members; - this._roomId = options.roomId; const powerLevelsObservable = options.powerLevelsObservable; this.track(powerLevelsObservable.subscribe(() => { /*resort based on new power levels here*/ })); @@ -44,7 +43,7 @@ export class MemberListViewModel extends ViewModel { _mapTileViewModels(members) { const mapper = (member, emitChange) => { const mediaRepository = this.mediaRepository; - const vm = new MemberTileViewModel(this.childOptions({member, emitChange, mediaRepository, roomId: this._roomId})); + const vm = new MemberTileViewModel(this.childOptions({member, emitChange, mediaRepository})); this.nameDisambiguator.disambiguate(vm); return vm; } diff --git a/src/domain/session/rightpanel/MemberTileViewModel.js b/src/domain/session/rightpanel/MemberTileViewModel.js index c9e460b2..eac6a6d4 100644 --- a/src/domain/session/rightpanel/MemberTileViewModel.js +++ b/src/domain/session/rightpanel/MemberTileViewModel.js @@ -24,7 +24,6 @@ export class MemberTileViewModel extends ViewModel { this._mediaRepository = options.mediaRepository this._previousName = null; this._nameChanged = true; - this._roomId = options.roomId; } get name() { @@ -48,7 +47,8 @@ export class MemberTileViewModel extends ViewModel { } get detailsUrl() { - return `${this.urlCreator.openRoomActionUrl(this._roomId)}/member/${this._member.userId}`; + const roomId = this.navigation.path.get("room").value; + return `${this.urlCreator.openRoomActionUrl(roomId)}/member/${this._member.userId}`; } _updatePreviousName(newName) { diff --git a/src/domain/session/rightpanel/RightPanelViewModel.js b/src/domain/session/rightpanel/RightPanelViewModel.js index c66f1755..670df868 100644 --- a/src/domain/session/rightpanel/RightPanelViewModel.js +++ b/src/domain/session/rightpanel/RightPanelViewModel.js @@ -36,7 +36,7 @@ export class RightPanelViewModel extends ViewModel { } const room = this._room; const powerLevelsObservable = await this._room.observePowerLevels(); - return {members: this._members, powerLevelsObservable, mediaRepository: room.mediaRepository, roomId: this._room.id}; + return {members: this._members, powerLevelsObservable, mediaRepository: room.mediaRepository}; } async _getMemberDetailsArguments() { From 4f4bc8f805428d4884422e0c6447f39059936fb1 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 6 Sep 2021 14:20:33 +0530 Subject: [PATCH 5/6] Add test Signed-off-by: RMidhunSuresh --- src/domain/navigation/index.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/domain/navigation/index.js b/src/domain/navigation/index.js index 821121b3..367d5bdc 100644 --- a/src/domain/navigation/index.js +++ b/src/domain/navigation/index.js @@ -327,6 +327,28 @@ export function tests() { assert.equal(segments[4].type, "details"); assert.equal(segments[4].value, true); }, + "open-room action should only copy over previous segments if there are no parts after open-room": assert => { + const nav = new Navigation(allowsChild); + const path = nav.pathFrom([ + new Segment("session", 1), + new Segment("rooms", ["a", "b", "c"]), + new Segment("room", "b"), + new Segment("right-panel", true), + new Segment("members", true) + ]); + const segments = parseUrlPath("/session/1/open-room/a/member/foo", path); + assert.equal(segments.length, 5); + assert.equal(segments[0].type, "session"); + assert.equal(segments[0].value, "1"); + assert.equal(segments[1].type, "rooms"); + assert.deepEqual(segments[1].value, ["a", "b", "c"]); + assert.equal(segments[2].type, "room"); + assert.equal(segments[2].value, "a"); + assert.equal(segments[3].type, "right-panel"); + assert.equal(segments[3].value, true); + assert.equal(segments[4].type, "member"); + assert.equal(segments[4].value, "foo"); + }, "parse open-room action setting a room in an empty tile": assert => { const nav = new Navigation(allowsChild); const path = nav.pathFrom([ From df74d0c814367c204d1b23f3b93060514cab434f Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 6 Sep 2021 17:41:36 +0530 Subject: [PATCH 6/6] Remove array from logic Signed-off-by: RMidhunSuresh --- src/domain/navigation/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/domain/navigation/index.js b/src/domain/navigation/index.js index 367d5bdc..470f872b 100644 --- a/src/domain/navigation/index.js +++ b/src/domain/navigation/index.js @@ -132,9 +132,9 @@ export function parseUrlPath(urlPath, currentNavPath, defaultSessionId) { segments.push(roomsSegmentWithRoom(rooms, roomId, currentNavPath)); } segments.push(new Segment("room", roomId)); - const partIndex = parts.findIndex(part => part === "open-room"); - const partsAfterRoom = parts.slice(partIndex + 1); - if (partsAfterRoom.length === 1) { + const openRoomPartIndex = parts.findIndex(part => part === "open-room"); + const hasOnlyRoomIdAfterPart = openRoomPartIndex >= parts.length - 2; + if (hasOnlyRoomIdAfterPart) { // Copy right-panel segments from previous path only if there are no other parts after open-room // fixes memberlist -> member details closing/opening grid view const previousSegments = currentNavPath.segments;