You've already forked element-web
mirror of
https://github.com/element-hq/element-web.git
synced 2025-12-01 09:58:03 +03:00
Ensure the right panel stays the same between room changes if possible
Fixes https://github.com/vector-im/riot-web/issues/10149
This commit is contained in:
@@ -28,7 +28,8 @@ import RateLimitedFunc from '../../ratelimitedfunc';
|
|||||||
import { showGroupInviteDialog, showGroupAddRoomDialog } from '../../GroupAddressPicker';
|
import { showGroupInviteDialog, showGroupAddRoomDialog } from '../../GroupAddressPicker';
|
||||||
import GroupStore from '../../stores/GroupStore';
|
import GroupStore from '../../stores/GroupStore';
|
||||||
import SettingsStore from "../../settings/SettingsStore";
|
import SettingsStore from "../../settings/SettingsStore";
|
||||||
import {RIGHT_PANEL_PHASES} from "../../stores/RightPanelStorePhases";
|
import {RIGHT_PANEL_PHASES, RIGHT_PANEL_PHASES_NO_ARGS} from "../../stores/RightPanelStorePhases";
|
||||||
|
import RightPanelStore from "../../stores/RightPanelStore";
|
||||||
|
|
||||||
export default class RightPanel extends React.Component {
|
export default class RightPanel extends React.Component {
|
||||||
static get propTypes() {
|
static get propTypes() {
|
||||||
@@ -63,12 +64,21 @@ export default class RightPanel extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_getPhaseFromProps() {
|
_getPhaseFromProps() {
|
||||||
|
const rps = RightPanelStore.getSharedInstance();
|
||||||
if (this.props.groupId) {
|
if (this.props.groupId) {
|
||||||
return RIGHT_PANEL_PHASES.GroupMemberList;
|
if (!RIGHT_PANEL_PHASES_NO_ARGS.includes(rps.groupPanelPhase)) {
|
||||||
|
rps.setPhase(RIGHT_PANEL_PHASES.GroupMemberList);
|
||||||
|
return RIGHT_PANEL_PHASES.GroupMemberList;
|
||||||
|
}
|
||||||
|
return rps.groupPanelPhase;
|
||||||
} else if (this.props.user) {
|
} else if (this.props.user) {
|
||||||
return RIGHT_PANEL_PHASES.RoomMemberInfo;
|
return RIGHT_PANEL_PHASES.RoomMemberInfo;
|
||||||
} else {
|
} else {
|
||||||
return RIGHT_PANEL_PHASES.RoomMemberList;
|
if (!RIGHT_PANEL_PHASES_NO_ARGS.includes(rps.roomPanelPhase)) {
|
||||||
|
rps.setPhase(RIGHT_PANEL_PHASES.RoomMemberList);
|
||||||
|
return RIGHT_PANEL_PHASES.RoomMemberList;
|
||||||
|
}
|
||||||
|
return rps.roomPanelPhase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
import dis from '../dispatcher';
|
import dis from '../dispatcher';
|
||||||
import {Store} from 'flux/utils';
|
import {Store} from 'flux/utils';
|
||||||
import SettingsStore, {SettingLevel} from "../settings/SettingsStore";
|
import SettingsStore, {SettingLevel} from "../settings/SettingsStore";
|
||||||
import {RIGHT_PANEL_PHASES} from "./RightPanelStorePhases";
|
import {RIGHT_PANEL_PHASES, RIGHT_PANEL_PHASES_NO_ARGS} from "./RightPanelStorePhases";
|
||||||
|
|
||||||
const INITIAL_STATE = {
|
const INITIAL_STATE = {
|
||||||
// Whether or not to show the right panel at all. We split out rooms and groups
|
// Whether or not to show the right panel at all. We split out rooms and groups
|
||||||
@@ -32,16 +32,6 @@ const INITIAL_STATE = {
|
|||||||
|
|
||||||
const GROUP_PHASES = Object.keys(RIGHT_PANEL_PHASES).filter(k => k.startsWith("Group"));
|
const GROUP_PHASES = Object.keys(RIGHT_PANEL_PHASES).filter(k => k.startsWith("Group"));
|
||||||
|
|
||||||
// These are the phases that are safe to persist (the ones that don't require additional
|
|
||||||
// arguments, basically).
|
|
||||||
const PHASES_TO_PERSIST = [
|
|
||||||
RIGHT_PANEL_PHASES.NotificationPanel,
|
|
||||||
RIGHT_PANEL_PHASES.FilePanel,
|
|
||||||
RIGHT_PANEL_PHASES.RoomMemberList,
|
|
||||||
RIGHT_PANEL_PHASES.GroupMemberList,
|
|
||||||
RIGHT_PANEL_PHASES.GroupRoomList,
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class for tracking the state of the right panel between layouts and
|
* A class for tracking the state of the right panel between layouts and
|
||||||
* sessions.
|
* sessions.
|
||||||
@@ -96,7 +86,7 @@ export default class RightPanelStore extends Store {
|
|||||||
this._state.showGroupPanel,
|
this._state.showGroupPanel,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (PHASES_TO_PERSIST.includes(this._state.lastRoomPhase)) {
|
if (RIGHT_PANEL_PHASES_NO_ARGS.includes(this._state.lastRoomPhase)) {
|
||||||
SettingsStore.setValue(
|
SettingsStore.setValue(
|
||||||
"lastRightPanelPhaseForRoom",
|
"lastRightPanelPhaseForRoom",
|
||||||
null,
|
null,
|
||||||
@@ -104,7 +94,7 @@ export default class RightPanelStore extends Store {
|
|||||||
this._state.lastRoomPhase,
|
this._state.lastRoomPhase,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (PHASES_TO_PERSIST.includes(this._state.lastGroupPhase)) {
|
if (RIGHT_PANEL_PHASES_NO_ARGS.includes(this._state.lastGroupPhase)) {
|
||||||
SettingsStore.setValue(
|
SettingsStore.setValue(
|
||||||
"lastRightPanelPhaseForGroup",
|
"lastRightPanelPhaseForGroup",
|
||||||
null,
|
null,
|
||||||
|
|||||||
@@ -29,3 +29,13 @@ export const RIGHT_PANEL_PHASES = Object.freeze({
|
|||||||
GroupRoomInfo: 'GroupRoomInfo',
|
GroupRoomInfo: 'GroupRoomInfo',
|
||||||
GroupMemberInfo: 'GroupMemberInfo',
|
GroupMemberInfo: 'GroupMemberInfo',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// These are the phases that are safe to persist (the ones that don't require additional
|
||||||
|
// arguments).
|
||||||
|
export const RIGHT_PANEL_PHASES_NO_ARGS = [
|
||||||
|
RIGHT_PANEL_PHASES.NotificationPanel,
|
||||||
|
RIGHT_PANEL_PHASES.FilePanel,
|
||||||
|
RIGHT_PANEL_PHASES.RoomMemberList,
|
||||||
|
RIGHT_PANEL_PHASES.GroupMemberList,
|
||||||
|
RIGHT_PANEL_PHASES.GroupRoomList,
|
||||||
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user