Keep memberlist panel open on room/grid change
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
d3a8e95962
commit
ea0851eb94
3 changed files with 21 additions and 13 deletions
|
@ -92,6 +92,16 @@ function pushRightPanelSegment(array, segment) {
|
||||||
array.push(new Segment(segment));
|
array.push(new Segment(segment));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function addPanelIfNeeded(navigation, panel, path) {
|
||||||
|
const segment = navigation.path.get(panel);
|
||||||
|
let _path = path;
|
||||||
|
if (segment?.value) {
|
||||||
|
_path = _path.with(navigation.segment("right-panel"));
|
||||||
|
_path = _path.with(segment)
|
||||||
|
}
|
||||||
|
return _path;
|
||||||
|
}
|
||||||
|
|
||||||
export function parseUrlPath(urlPath, currentNavPath, defaultSessionId) {
|
export function parseUrlPath(urlPath, currentNavPath, defaultSessionId) {
|
||||||
// substr(1) to take of initial /
|
// substr(1) to take of initial /
|
||||||
const parts = urlPath.substr(1).split("/");
|
const parts = urlPath.substr(1).split("/");
|
||||||
|
@ -122,6 +132,8 @@ export function parseUrlPath(urlPath, currentNavPath, defaultSessionId) {
|
||||||
segments.push(new Segment("room", roomId));
|
segments.push(new Segment("room", roomId));
|
||||||
if (currentNavPath.get("details")?.value) {
|
if (currentNavPath.get("details")?.value) {
|
||||||
pushRightPanelSegment(segments, "details");
|
pushRightPanelSegment(segments, "details");
|
||||||
|
} else if (currentNavPath.get("members")?.value) {
|
||||||
|
pushRightPanelSegment(segments, "members");
|
||||||
}
|
}
|
||||||
} else if (type === "last-session") {
|
} else if (type === "last-session") {
|
||||||
let sessionSegment = currentNavPath.get("session");
|
let sessionSegment = currentNavPath.get("session");
|
||||||
|
|
|
@ -15,6 +15,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ViewModel} from "../ViewModel.js";
|
import {ViewModel} from "../ViewModel.js";
|
||||||
|
import {addPanelIfNeeded} from "../navigation/index.js";
|
||||||
|
|
||||||
function dedupeSparse(roomIds) {
|
function dedupeSparse(roomIds) {
|
||||||
return roomIds.map((id, idx) => {
|
return roomIds.map((id, idx) => {
|
||||||
|
@ -79,13 +80,10 @@ export class RoomGridViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
_switchToRoom(roomId) {
|
_switchToRoom(roomId) {
|
||||||
const detailsShown = !!this.navigation.path.get("details")?.value;
|
|
||||||
let path = this.navigation.path.until("rooms");
|
let path = this.navigation.path.until("rooms");
|
||||||
path = path.with(this.navigation.segment("room", roomId));
|
path = path.with(this.navigation.segment("room", roomId));
|
||||||
if (detailsShown) {
|
path = addPanelIfNeeded(this.navigation, "details", path);
|
||||||
path = path.with(this.navigation.segment("right-panel", true));
|
path = addPanelIfNeeded(this.navigation, "members", path);
|
||||||
path = path.with(this.navigation.segment("details", true));
|
|
||||||
}
|
|
||||||
this.navigation.applyPath(path);
|
this.navigation.applyPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import {RoomTileViewModel} from "./RoomTileViewModel.js";
|
||||||
import {InviteTileViewModel} from "./InviteTileViewModel.js";
|
import {InviteTileViewModel} from "./InviteTileViewModel.js";
|
||||||
import {RoomFilter} from "./RoomFilter.js";
|
import {RoomFilter} from "./RoomFilter.js";
|
||||||
import {ApplyMap} from "../../../observable/map/ApplyMap.js";
|
import {ApplyMap} from "../../../observable/map/ApplyMap.js";
|
||||||
|
import {addPanelIfNeeded} from "../../navigation/index.js";
|
||||||
|
|
||||||
export class LeftPanelViewModel extends ViewModel {
|
export class LeftPanelViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
|
@ -92,13 +93,10 @@ export class LeftPanelViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_pathForDetails(path) {
|
_pathForRightPanel(path) {
|
||||||
let _path = path;
|
let _path = path;
|
||||||
const details = this.navigation.path.get("details");
|
_path = addPanelIfNeeded(this.navigation, "details", _path);
|
||||||
if (details?.value) {
|
_path = addPanelIfNeeded(this.navigation, "members", _path);
|
||||||
_path = _path.with(this.navigation.segment("right-panel"));
|
|
||||||
_path = _path.with(details)
|
|
||||||
}
|
|
||||||
return _path;
|
return _path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,13 +106,13 @@ export class LeftPanelViewModel extends ViewModel {
|
||||||
if (this.gridEnabled) {
|
if (this.gridEnabled) {
|
||||||
if (room) {
|
if (room) {
|
||||||
path = path.with(room);
|
path = path.with(room);
|
||||||
path = this._pathForDetails(path);
|
path = this._pathForRightPanel(path);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (room) {
|
if (room) {
|
||||||
path = path.with(this.navigation.segment("rooms", [room.value]));
|
path = path.with(this.navigation.segment("rooms", [room.value]));
|
||||||
path = path.with(room);
|
path = path.with(room);
|
||||||
path = this._pathForDetails(path);
|
path = this._pathForRightPanel(path);
|
||||||
} else {
|
} else {
|
||||||
path = path.with(this.navigation.segment("rooms", []));
|
path = path.with(this.navigation.segment("rooms", []));
|
||||||
path = path.with(this.navigation.segment("empty-grid-tile", 0));
|
path = path.with(this.navigation.segment("empty-grid-tile", 0));
|
||||||
|
|
Reference in a new issue