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));
|
||||
}
|
||||
|
||||
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) {
|
||||
// substr(1) to take of initial /
|
||||
const parts = urlPath.substr(1).split("/");
|
||||
|
@ -122,6 +132,8 @@ export function parseUrlPath(urlPath, currentNavPath, defaultSessionId) {
|
|||
segments.push(new Segment("room", roomId));
|
||||
if (currentNavPath.get("details")?.value) {
|
||||
pushRightPanelSegment(segments, "details");
|
||||
} else if (currentNavPath.get("members")?.value) {
|
||||
pushRightPanelSegment(segments, "members");
|
||||
}
|
||||
} else if (type === "last-session") {
|
||||
let sessionSegment = currentNavPath.get("session");
|
||||
|
|
|
@ -15,6 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import {ViewModel} from "../ViewModel.js";
|
||||
import {addPanelIfNeeded} from "../navigation/index.js";
|
||||
|
||||
function dedupeSparse(roomIds) {
|
||||
return roomIds.map((id, idx) => {
|
||||
|
@ -79,13 +80,10 @@ export class RoomGridViewModel extends ViewModel {
|
|||
}
|
||||
|
||||
_switchToRoom(roomId) {
|
||||
const detailsShown = !!this.navigation.path.get("details")?.value;
|
||||
let path = this.navigation.path.until("rooms");
|
||||
path = path.with(this.navigation.segment("room", roomId));
|
||||
if (detailsShown) {
|
||||
path = path.with(this.navigation.segment("right-panel", true));
|
||||
path = path.with(this.navigation.segment("details", true));
|
||||
}
|
||||
path = addPanelIfNeeded(this.navigation, "details", path);
|
||||
path = addPanelIfNeeded(this.navigation, "members", path);
|
||||
this.navigation.applyPath(path);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import {RoomTileViewModel} from "./RoomTileViewModel.js";
|
|||
import {InviteTileViewModel} from "./InviteTileViewModel.js";
|
||||
import {RoomFilter} from "./RoomFilter.js";
|
||||
import {ApplyMap} from "../../../observable/map/ApplyMap.js";
|
||||
import {addPanelIfNeeded} from "../../navigation/index.js";
|
||||
|
||||
export class LeftPanelViewModel extends ViewModel {
|
||||
constructor(options) {
|
||||
|
@ -92,13 +93,10 @@ export class LeftPanelViewModel extends ViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
_pathForDetails(path) {
|
||||
_pathForRightPanel(path) {
|
||||
let _path = path;
|
||||
const details = this.navigation.path.get("details");
|
||||
if (details?.value) {
|
||||
_path = _path.with(this.navigation.segment("right-panel"));
|
||||
_path = _path.with(details)
|
||||
}
|
||||
_path = addPanelIfNeeded(this.navigation, "details", _path);
|
||||
_path = addPanelIfNeeded(this.navigation, "members", _path);
|
||||
return _path;
|
||||
}
|
||||
|
||||
|
@ -108,13 +106,13 @@ export class LeftPanelViewModel extends ViewModel {
|
|||
if (this.gridEnabled) {
|
||||
if (room) {
|
||||
path = path.with(room);
|
||||
path = this._pathForDetails(path);
|
||||
path = this._pathForRightPanel(path);
|
||||
}
|
||||
} else {
|
||||
if (room) {
|
||||
path = path.with(this.navigation.segment("rooms", [room.value]));
|
||||
path = path.with(room);
|
||||
path = this._pathForDetails(path);
|
||||
path = this._pathForRightPanel(path);
|
||||
} else {
|
||||
path = path.with(this.navigation.segment("rooms", []));
|
||||
path = path.with(this.navigation.segment("empty-grid-tile", 0));
|
||||
|
|
Reference in a new issue