Fix RoomViewStore forgetting some details of a view room call (#7512)
This commit is contained in:
parent
3a18fd8f71
commit
ec6c1b8272
21 changed files with 67 additions and 57 deletions
|
@ -56,7 +56,7 @@ import AccessibleButton from "../views/elements/AccessibleButton";
|
||||||
import RightPanelStore from "../../stores/right-panel/RightPanelStore";
|
import RightPanelStore from "../../stores/right-panel/RightPanelStore";
|
||||||
import { haveTileForEvent } from "../views/rooms/EventTile";
|
import { haveTileForEvent } from "../views/rooms/EventTile";
|
||||||
import RoomContext, { TimelineRenderingType } from "../../contexts/RoomContext";
|
import RoomContext, { TimelineRenderingType } from "../../contexts/RoomContext";
|
||||||
import MatrixClientContext, { withMatrixClientHOC, MatrixClientProps } from "../../contexts/MatrixClientContext";
|
import MatrixClientContext, { MatrixClientProps, withMatrixClientHOC } from "../../contexts/MatrixClientContext";
|
||||||
import { E2EStatus, shieldStatusForRoom } from '../../utils/ShieldUtils';
|
import { E2EStatus, shieldStatusForRoom } from '../../utils/ShieldUtils';
|
||||||
import { Action } from "../../dispatcher/actions";
|
import { Action } from "../../dispatcher/actions";
|
||||||
import { IMatrixClientCreds } from "../../MatrixClientPeg";
|
import { IMatrixClientCreds } from "../../MatrixClientPeg";
|
||||||
|
@ -1777,7 +1777,10 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
onHiddenHighlightsClick = () => {
|
onHiddenHighlightsClick = () => {
|
||||||
const oldRoom = this.getOldRoom();
|
const oldRoom = this.getOldRoom();
|
||||||
if (!oldRoom) return;
|
if (!oldRoom) return;
|
||||||
dis.dispatch({ action: "view_room", room_id: oldRoom.roomId });
|
dis.dispatch({
|
||||||
|
action: Action.ViewRoom,
|
||||||
|
room_id: oldRoom.roomId,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -327,7 +327,7 @@ export const showRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: st
|
||||||
|
|
||||||
const roomAlias = getDisplayAliasForRoom(room) || undefined;
|
const roomAlias = getDisplayAliasForRoom(room) || undefined;
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
should_peek: true,
|
should_peek: true,
|
||||||
_type: "room_directory", // instrumentation
|
_type: "room_directory", // instrumentation
|
||||||
room_alias: roomAlias,
|
room_alias: roomAlias,
|
||||||
|
|
|
@ -834,7 +834,7 @@ export default class SpaceRoomView extends React.PureComponent<IProps, IState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private onAction = (payload: ActionPayload) => {
|
private onAction = (payload: ActionPayload) => {
|
||||||
if (payload.action === "view_room" && payload.room_id === this.props.space.roomId) {
|
if (payload.action === Action.ViewRoom && payload.room_id === this.props.space.roomId) {
|
||||||
this.setState({ phase: Phase.Landing });
|
this.setState({ phase: Phase.Landing });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -862,7 +862,7 @@ export default class SpaceRoomView extends React.PureComponent<IProps, IState> {
|
||||||
private goToFirstRoom = async () => {
|
private goToFirstRoom = async () => {
|
||||||
if (this.state.firstRoomId) {
|
if (this.state.firstRoomId) {
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: this.state.firstRoomId,
|
room_id: this.state.firstRoomId,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -43,6 +43,7 @@ import { ROOM_NOTIFICATIONS_TAB } from "../dialogs/RoomSettingsDialog";
|
||||||
import { useEventEmitterState } from "../../../hooks/useEventEmitter";
|
import { useEventEmitterState } from "../../../hooks/useEventEmitter";
|
||||||
import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
|
import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
|
||||||
import DMRoomMap from "../../../utils/DMRoomMap";
|
import DMRoomMap from "../../../utils/DMRoomMap";
|
||||||
|
import { Action } from "../../../dispatcher/actions";
|
||||||
|
|
||||||
interface IProps extends IContextMenuProps {
|
interface IProps extends IContextMenuProps {
|
||||||
room: Room;
|
room: Room;
|
||||||
|
@ -239,7 +240,7 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => {
|
||||||
const ensureViewingRoom = () => {
|
const ensureViewingRoom = () => {
|
||||||
if (RoomViewStore.getRoomId() === room.roomId) return;
|
if (RoomViewStore.getRoomId() === room.roomId) return;
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: room.roomId,
|
room_id: room.roomId,
|
||||||
}, true);
|
}, true);
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,9 +18,7 @@ import React, { useContext } from "react";
|
||||||
import { Room } from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
import { EventType } from "matrix-js-sdk/src/@types/event";
|
import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||||
|
|
||||||
import {
|
import { IProps as IContextMenuProps } from "../../structures/ContextMenu";
|
||||||
IProps as IContextMenuProps,
|
|
||||||
} from "../../structures/ContextMenu";
|
|
||||||
import IconizedContextMenu, { IconizedContextMenuOption, IconizedContextMenuOptionList } from "./IconizedContextMenu";
|
import IconizedContextMenu, { IconizedContextMenuOption, IconizedContextMenuOptionList } from "./IconizedContextMenu";
|
||||||
import { _t } from "../../../languageHandler";
|
import { _t } from "../../../languageHandler";
|
||||||
import {
|
import {
|
||||||
|
@ -180,7 +178,7 @@ const SpaceContextMenu = ({ space, hideHeader, onFinished, ...props }: IProps) =
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: space.roomId,
|
room_id: space.roomId,
|
||||||
});
|
});
|
||||||
onFinished();
|
onFinished();
|
||||||
|
|
|
@ -227,7 +227,7 @@ const CreateSpaceFromCommunityDialog: React.FC<IProps> = ({ matrixClient: cli, g
|
||||||
|
|
||||||
const onSpaceClick = () => {
|
const onSpaceClick = () => {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: roomId,
|
room_id: roomId,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { useMemo, useState, useEffect } from "react";
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
import { Room } from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
|
@ -23,7 +23,7 @@ import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||||
|
|
||||||
import { _t } from "../../../languageHandler";
|
import { _t } from "../../../languageHandler";
|
||||||
import dis from "../../../dispatcher/dispatcher";
|
import dis from "../../../dispatcher/dispatcher";
|
||||||
import { useSettingValue, useFeatureEnabled } from "../../../hooks/useSettings";
|
import { useFeatureEnabled, useSettingValue } from "../../../hooks/useSettings";
|
||||||
import { UIFeature } from "../../../settings/UIFeature";
|
import { UIFeature } from "../../../settings/UIFeature";
|
||||||
import { Layout } from "../../../settings/enums/Layout";
|
import { Layout } from "../../../settings/enums/Layout";
|
||||||
import { IDialogProps } from "./IDialogProps";
|
import { IDialogProps } from "./IDialogProps";
|
||||||
|
@ -45,6 +45,7 @@ import EntityTile from "../rooms/EntityTile";
|
||||||
import BaseAvatar from "../avatars/BaseAvatar";
|
import BaseAvatar from "../avatars/BaseAvatar";
|
||||||
import SpaceStore from "../../../stores/spaces/SpaceStore";
|
import SpaceStore from "../../../stores/spaces/SpaceStore";
|
||||||
import { roomContextDetailsText } from "../../../Rooms";
|
import { roomContextDetailsText } from "../../../Rooms";
|
||||||
|
import { Action } from "../../../dispatcher/actions";
|
||||||
|
|
||||||
const AVATAR_SIZE = 30;
|
const AVATAR_SIZE = 30;
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ const Entry: React.FC<IEntryProps> = ({ room, event, matrixClient: cli, onFinish
|
||||||
|
|
||||||
const jumpToRoom = () => {
|
const jumpToRoom = () => {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: room.roomId,
|
room_id: room.roomId,
|
||||||
});
|
});
|
||||||
onFinished(true);
|
onFinished(true);
|
||||||
|
|
|
@ -221,7 +221,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", onFinished }) =>
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
action: 'view_room',
|
action: Action.ViewRoom,
|
||||||
room_id: roomId,
|
room_id: roomId,
|
||||||
});
|
});
|
||||||
onFinished();
|
onFinished();
|
||||||
|
|
|
@ -25,6 +25,7 @@ import RoomAvatar from "../avatars/RoomAvatar";
|
||||||
import dis from "../../../dispatcher/dispatcher";
|
import dis from "../../../dispatcher/dispatcher";
|
||||||
import InteractiveTooltip, { Direction } from "../elements/InteractiveTooltip";
|
import InteractiveTooltip, { Direction } from "../elements/InteractiveTooltip";
|
||||||
import { roomContextDetailsText } from "../../../Rooms";
|
import { roomContextDetailsText } from "../../../Rooms";
|
||||||
|
import { Action } from "../../../dispatcher/actions";
|
||||||
|
|
||||||
const RecentlyViewedButton = () => {
|
const RecentlyViewedButton = () => {
|
||||||
const tooltipRef = useRef<InteractiveTooltip>();
|
const tooltipRef = useRef<InteractiveTooltip>();
|
||||||
|
@ -40,7 +41,7 @@ const RecentlyViewedButton = () => {
|
||||||
key={crumb.roomId}
|
key={crumb.roomId}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: crumb.roomId,
|
room_id: crumb.roomId,
|
||||||
});
|
});
|
||||||
tooltipRef.current?.hideTooltip();
|
tooltipRef.current?.hideTooltip();
|
||||||
|
|
|
@ -27,6 +27,7 @@ import { UPDATE_EVENT } from "../../../stores/AsyncStore";
|
||||||
import { RovingAccessibleTooltipButton } from "../../../accessibility/RovingTabIndex";
|
import { RovingAccessibleTooltipButton } from "../../../accessibility/RovingTabIndex";
|
||||||
import Toolbar from "../../../accessibility/Toolbar";
|
import Toolbar from "../../../accessibility/Toolbar";
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
|
import { Action } from "../../../dispatcher/actions";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
}
|
}
|
||||||
|
@ -78,7 +79,10 @@ export default class RoomBreadcrumbs extends React.PureComponent<IProps, IState>
|
||||||
|
|
||||||
private viewRoom = (room: Room, index: number) => {
|
private viewRoom = (room: Room, index: number) => {
|
||||||
Analytics.trackEvent("Breadcrumbs", "click_node", String(index));
|
Analytics.trackEvent("Breadcrumbs", "click_node", String(index));
|
||||||
defaultDispatcher.dispatch({ action: "view_room", room_id: room.roomId });
|
defaultDispatcher.dispatch({
|
||||||
|
action: Action.ViewRoom,
|
||||||
|
room_id: room.roomId,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
public render(): React.ReactElement {
|
public render(): React.ReactElement {
|
||||||
|
|
|
@ -47,12 +47,12 @@ import AccessibleButton from "../elements/AccessibleButton";
|
||||||
import { CommunityPrototypeStore } from "../../../stores/CommunityPrototypeStore";
|
import { CommunityPrototypeStore } from "../../../stores/CommunityPrototypeStore";
|
||||||
import SpaceStore from "../../../stores/spaces/SpaceStore";
|
import SpaceStore from "../../../stores/spaces/SpaceStore";
|
||||||
import {
|
import {
|
||||||
|
isMetaSpace,
|
||||||
ISuggestedRoom,
|
ISuggestedRoom,
|
||||||
MetaSpace,
|
MetaSpace,
|
||||||
SpaceKey,
|
SpaceKey,
|
||||||
UPDATE_SUGGESTED_ROOMS,
|
|
||||||
UPDATE_SELECTED_SPACE,
|
UPDATE_SELECTED_SPACE,
|
||||||
isMetaSpace,
|
UPDATE_SUGGESTED_ROOMS,
|
||||||
} from "../../../stores/spaces";
|
} from "../../../stores/spaces";
|
||||||
import { shouldShowSpaceInvite, showAddExistingRooms, showCreateNewRoom, showSpaceInvite } from "../../../utils/space";
|
import { shouldShowSpaceInvite, showAddExistingRooms, showCreateNewRoom, showSpaceInvite } from "../../../utils/space";
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
|
@ -215,7 +215,7 @@ const UntaggedAuxButton = ({ tabIndex }: IAuxButtonProps) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
closeMenu();
|
closeMenu();
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: activeSpace.roomId,
|
room_id: activeSpace.roomId,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
@ -497,7 +497,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
||||||
private onExplore = () => {
|
private onExplore = () => {
|
||||||
if (!isMetaSpace(this.props.activeSpace)) {
|
if (!isMetaSpace(this.props.activeSpace)) {
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: this.props.activeSpace,
|
room_id: this.props.activeSpace,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -522,7 +522,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
||||||
);
|
);
|
||||||
const viewRoom = () => {
|
const viewRoom = () => {
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_alias: room.canonical_alias || room.aliases?.[0],
|
room_alias: room.canonical_alias || room.aliases?.[0],
|
||||||
room_id: room.room_id,
|
room_id: room.room_id,
|
||||||
via_servers: room.viaServers,
|
via_servers: room.viaServers,
|
||||||
|
|
|
@ -97,7 +97,7 @@ const PrototypeCommunityContextMenu = (props: ComponentProps<typeof SpaceContext
|
||||||
const chat = CommunityPrototypeStore.instance.getSelectedCommunityGeneralChat();
|
const chat = CommunityPrototypeStore.instance.getSelectedCommunityGeneralChat();
|
||||||
if (chat) {
|
if (chat) {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_room',
|
action: Action.ViewRoom,
|
||||||
room_id: chat.roomId,
|
room_id: chat.roomId,
|
||||||
}, true);
|
}, true);
|
||||||
RightPanelStore.instance.setCard({ phase: RightPanelPhases.RoomMemberList }, undefined, chat.roomId);
|
RightPanelStore.instance.setCard({ phase: RightPanelPhases.RoomMemberList }, undefined, chat.roomId);
|
||||||
|
|
|
@ -294,7 +294,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
private onAction = (payload: ActionPayload) => {
|
private onAction = (payload: ActionPayload) => {
|
||||||
if (payload.action === "view_room" && payload.show_room_tile && this.state.rooms) {
|
if (payload.action === Action.ViewRoom && payload.show_room_tile && this.state.rooms) {
|
||||||
// XXX: we have to do this a tick later because we have incorrect intermediate props during a room change
|
// XXX: we have to do this a tick later because we have incorrect intermediate props during a room change
|
||||||
// where we lose the room we are changing from temporarily and then it comes back in an update right after.
|
// where we lose the room we are changing from temporarily and then it comes back in an update right after.
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
|
|
|
@ -197,7 +197,10 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private onAction = (payload: ActionPayload) => {
|
private onAction = (payload: ActionPayload) => {
|
||||||
if (payload.action === "view_room" && payload.room_id === this.props.room.roomId && payload.show_room_tile) {
|
if (payload.action === Action.ViewRoom &&
|
||||||
|
payload.room_id === this.props.room.roomId &&
|
||||||
|
payload.show_room_tile
|
||||||
|
) {
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
this.scrollIntoView();
|
this.scrollIntoView();
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,6 +33,7 @@ import { arrayHasDiff } from "../../../utils/arrays";
|
||||||
import { useLocalEcho } from "../../../hooks/useLocalEcho";
|
import { useLocalEcho } from "../../../hooks/useLocalEcho";
|
||||||
import dis from "../../../dispatcher/dispatcher";
|
import dis from "../../../dispatcher/dispatcher";
|
||||||
import { ROOM_SECURITY_TAB } from "../dialogs/RoomSettingsDialog";
|
import { ROOM_SECURITY_TAB } from "../dialogs/RoomSettingsDialog";
|
||||||
|
import { Action } from "../../../dispatcher/actions";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
room: Room;
|
room: Room;
|
||||||
|
@ -267,7 +268,7 @@ const JoinRuleSettings = ({ room, promptUpgrade, aliasWarning, onError, beforeCh
|
||||||
|
|
||||||
// switch to the new room in the background
|
// switch to the new room in the background
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: roomId,
|
room_id: roomId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ import { useDispatcher } from "../../../../../hooks/useDispatcher";
|
||||||
import { CreateEventField, IGroupSummary } from "../../../dialogs/CreateSpaceFromCommunityDialog";
|
import { CreateEventField, IGroupSummary } from "../../../dialogs/CreateSpaceFromCommunityDialog";
|
||||||
import { createSpaceFromCommunity } from "../../../../../utils/space";
|
import { createSpaceFromCommunity } from "../../../../../utils/space";
|
||||||
import Spinner from "../../../elements/Spinner";
|
import Spinner from "../../../elements/Spinner";
|
||||||
|
import { Action } from "../../../../../dispatcher/actions";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
closeSettingsFn(success: boolean): void;
|
closeSettingsFn(success: boolean): void;
|
||||||
|
@ -112,7 +113,7 @@ const CommunityMigrator = ({ onFinished }) => {
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (community.spaceId) {
|
if (community.spaceId) {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: community.spaceId,
|
room_id: community.spaceId,
|
||||||
});
|
});
|
||||||
onFinished();
|
onFinished();
|
||||||
|
|
|
@ -116,7 +116,10 @@ function onUserClick(event: MouseEvent, userId: string) {
|
||||||
}
|
}
|
||||||
function onAliasClick(event: MouseEvent, roomAlias: string) {
|
function onAliasClick(event: MouseEvent, roomAlias: string) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
dis.dispatch({ action: 'view_room', room_alias: roomAlias });
|
dis.dispatch({
|
||||||
|
action: Action.ViewRoom,
|
||||||
|
room_alias: roomAlias,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
function onGroupClick(event: MouseEvent, groupId: string) {
|
function onGroupClick(event: MouseEvent, groupId: string) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
@ -251,16 +251,10 @@ class RoomViewStore extends Store<ActionPayload> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-fire the payload with the newly found room_id
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: Action.ViewRoom,
|
...payload,
|
||||||
room_id: roomId,
|
room_id: roomId,
|
||||||
event_id: payload.event_id,
|
|
||||||
highlighted: payload.highlighted,
|
|
||||||
room_alias: payload.room_alias,
|
|
||||||
auto_join: payload.auto_join,
|
|
||||||
oob_data: payload.oob_data,
|
|
||||||
viaServers: payload.via_servers,
|
|
||||||
wasContextSwitch: payload.context_switch,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,44 +362,43 @@ export default class RightPanelStore extends ReadyWatchingStore {
|
||||||
// this.loadCacheFromSettings();
|
// this.loadCacheFromSettings();
|
||||||
};
|
};
|
||||||
|
|
||||||
onDispatch(payload: ActionPayload) {
|
onDispatch = (payload: ActionPayload) => {
|
||||||
switch (payload.action) {
|
switch (payload.action) {
|
||||||
case 'view_group':
|
case 'view_group':
|
||||||
case Action.ViewRoom: {
|
case Action.ViewRoom: {
|
||||||
const _this = RightPanelStore.instance;
|
if (payload.room_id === this.viewedRoomId) break; // skip this transition, probably a permalink
|
||||||
if (payload.room_id === _this.viewedRoomId) break; // skip this transition, probably a permalink
|
|
||||||
|
|
||||||
// Put group in the same/similar view to what was open from the previously viewed room
|
// Put group in the same/similar view to what was open from the previously viewed room
|
||||||
// Is contradictory to the new "per room" philosophy but it is the legacy behavior for groups.
|
// Is contradictory to the new "per room" philosophy but it is the legacy behavior for groups.
|
||||||
if ((_this.isViewingRoom ? Action.ViewRoom : "view_group") != payload.action) {
|
if ((this.isViewingRoom ? Action.ViewRoom : "view_group") != payload.action) {
|
||||||
if (payload.action == Action.ViewRoom && MEMBER_INFO_PHASES.includes(_this.currentCard?.phase)) {
|
if (payload.action == Action.ViewRoom && MEMBER_INFO_PHASES.includes(this.currentCard?.phase)) {
|
||||||
// switch from group to room
|
// switch from group to room
|
||||||
_this.setRightPanelCache({ phase: RightPanelPhases.RoomMemberList, state: {} });
|
this.setRightPanelCache({ phase: RightPanelPhases.RoomMemberList, state: {} });
|
||||||
} else if (
|
} else if (
|
||||||
payload.action == "view_group" &&
|
payload.action == "view_group" &&
|
||||||
_this.currentCard?.phase === RightPanelPhases.GroupMemberInfo
|
this.currentCard?.phase === RightPanelPhases.GroupMemberInfo
|
||||||
) {
|
) {
|
||||||
// switch from room to group
|
// switch from room to group
|
||||||
_this.setRightPanelCache({ phase: RightPanelPhases.GroupMemberList, state: {} });
|
this.setRightPanelCache({ phase: RightPanelPhases.GroupMemberList, state: {} });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the current room here, so that all the other functions dont need to be room dependant.
|
// Update the current room here, so that all the other functions dont need to be room dependant.
|
||||||
// The right panel store always will return the state for the current room.
|
// The right panel store always will return the state for the current room.
|
||||||
_this.viewedRoomId = payload.room_id;
|
this.viewedRoomId = payload.room_id;
|
||||||
_this.isViewingRoom = payload.action == Action.ViewRoom;
|
this.isViewingRoom = payload.action == Action.ViewRoom;
|
||||||
// load values from byRoomCache with the viewedRoomId.
|
// load values from byRoomCache with the viewedRoomId.
|
||||||
if (_this.isReady) {
|
if (this.isReady) {
|
||||||
// we need the client to be ready to get the events form the ids of the settings
|
// we need the client to be ready to get the events form the ids of the settings
|
||||||
// the loading will be done in the onReady function (to catch up with the changes done here before it was ready)
|
// the loading will be done in the onReady function (to catch up with the changes done here before it was ready)
|
||||||
// all the logic in this case is not necessary anymore as soon as groups are dropped and we use: onRoomViewStoreUpdate
|
// all the logic in this case is not necessary anymore as soon as groups are dropped and we use: onRoomViewStoreUpdate
|
||||||
_this.loadCacheFromSettings();
|
this.loadCacheFromSettings();
|
||||||
_this.emitAndUpdateSettings();
|
this.emitAndUpdateSettings();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
public static get instance(): RightPanelStore {
|
public static get instance(): RightPanelStore {
|
||||||
if (!RightPanelStore.internalInstance) {
|
if (!RightPanelStore.internalInstance) {
|
||||||
|
|
|
@ -157,7 +157,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
if (space) {
|
if (space) {
|
||||||
const roomId = this.getNotificationState(space).getFirstRoomWithNotifications();
|
const roomId = this.getNotificationState(space).getFirstRoomWithNotifications();
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: roomId,
|
room_id: roomId,
|
||||||
context_switch: true,
|
context_switch: true,
|
||||||
});
|
});
|
||||||
|
@ -174,7 +174,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
});
|
});
|
||||||
if (unreadRoom) {
|
if (unreadRoom) {
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: unreadRoom.roomId,
|
room_id: unreadRoom.roomId,
|
||||||
context_switch: true,
|
context_switch: true,
|
||||||
});
|
});
|
||||||
|
@ -222,13 +222,13 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
this.isRoomInSpace(space, roomId)
|
this.isRoomInSpace(space, roomId)
|
||||||
) {
|
) {
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: roomId,
|
room_id: roomId,
|
||||||
context_switch: true,
|
context_switch: true,
|
||||||
});
|
});
|
||||||
} else if (cliSpace) {
|
} else if (cliSpace) {
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
action: "view_room",
|
action: Action.ViewRoom,
|
||||||
room_id: space,
|
room_id: space,
|
||||||
context_switch: true,
|
context_switch: true,
|
||||||
});
|
});
|
||||||
|
@ -1061,7 +1061,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
if (!spacesEnabled || !this.matrixClient) return;
|
if (!spacesEnabled || !this.matrixClient) return;
|
||||||
|
|
||||||
switch (payload.action) {
|
switch (payload.action) {
|
||||||
case "view_room": {
|
case Action.ViewRoom: {
|
||||||
// Don't auto-switch rooms when reacting to a context-switch or for new rooms being created
|
// Don't auto-switch rooms when reacting to a context-switch or for new rooms being created
|
||||||
// as this is not helpful and can create loops of rooms/space switching
|
// as this is not helpful and can create loops of rooms/space switching
|
||||||
if (payload.context_switch || payload.justCreatedOpts) break;
|
if (payload.context_switch || payload.justCreatedOpts) break;
|
||||||
|
|
|
@ -34,6 +34,7 @@ import { MatrixClientPeg } from "../../src/MatrixClientPeg";
|
||||||
import defaultDispatcher from "../../src/dispatcher/dispatcher";
|
import defaultDispatcher from "../../src/dispatcher/dispatcher";
|
||||||
import SettingsStore from "../../src/settings/SettingsStore";
|
import SettingsStore from "../../src/settings/SettingsStore";
|
||||||
import { SettingLevel } from "../../src/settings/SettingLevel";
|
import { SettingLevel } from "../../src/settings/SettingLevel";
|
||||||
|
import { Action } from "../../src/dispatcher/actions";
|
||||||
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@ describe("SpaceStore", () => {
|
||||||
let rooms = [];
|
let rooms = [];
|
||||||
const mkRoom = (roomId: string) => testUtils.mkRoom(client, roomId, rooms);
|
const mkRoom = (roomId: string) => testUtils.mkRoom(client, roomId, rooms);
|
||||||
const mkSpace = (spaceId: string, children: string[] = []) => testUtils.mkSpace(client, spaceId, rooms, children);
|
const mkSpace = (spaceId: string, children: string[] = []) => testUtils.mkSpace(client, spaceId, rooms, children);
|
||||||
const viewRoom = roomId => defaultDispatcher.dispatch({ action: "view_room", room_id: roomId }, true);
|
const viewRoom = roomId => defaultDispatcher.dispatch({ action: Action.ViewRoom, room_id: roomId }, true);
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
client.getRoom.mockImplementation(roomId => rooms.find(room => room.roomId === roomId));
|
client.getRoom.mockImplementation(roomId => rooms.find(room => room.roomId === roomId));
|
||||||
|
@ -680,7 +681,7 @@ describe("SpaceStore", () => {
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
dispatcherRef = defaultDispatcher.register(payload => {
|
dispatcherRef = defaultDispatcher.register(payload => {
|
||||||
if (payload.action === "view_room" || payload.action === "view_home_page") {
|
if (payload.action === Action.ViewRoom || payload.action === "view_home_page") {
|
||||||
currentRoom = payload.room_id || null;
|
currentRoom = payload.room_id || null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue