Remove space-specific right panel store handling

This is no longer needed as the right panel always corresponds to the currently viewed room/space only.

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2024-11-25 17:29:32 +00:00
parent a2a066d8b4
commit 3f221891f7
No known key found for this signature in database
GPG key ID: A2B008A5F49F5D0D
21 changed files with 53 additions and 83 deletions

View file

@ -109,10 +109,10 @@ export default class RightPanel extends React.Component<Props, IState> {
} }
// redraw the badge on the membership list // redraw the badge on the membership list
if (this.state.phase === RightPanelPhases.RoomMemberList) { if (this.state.phase === RightPanelPhases.MemberList) {
this.delayedUpdate(); this.delayedUpdate();
} else if ( } else if (
this.state.phase === RightPanelPhases.RoomMemberInfo && this.state.phase === RightPanelPhases.MemberInfo &&
member.userId === this.state.cardState?.member?.userId member.userId === this.state.cardState?.member?.userId
) { ) {
// refresh the member info (e.g. new power level) // refresh the member info (e.g. new power level)
@ -157,7 +157,7 @@ export default class RightPanel extends React.Component<Props, IState> {
const phase = this.props.overwriteCard?.phase ?? this.state.phase; const phase = this.props.overwriteCard?.phase ?? this.state.phase;
const cardState = this.props.overwriteCard?.state ?? this.state.cardState; const cardState = this.props.overwriteCard?.state ?? this.state.cardState;
switch (phase) { switch (phase) {
case RightPanelPhases.RoomMemberList: case RightPanelPhases.MemberList:
if (!!roomId) { if (!!roomId) {
card = ( card = (
<MemberList <MemberList
@ -170,22 +170,8 @@ export default class RightPanel extends React.Component<Props, IState> {
); );
} }
break; break;
case RightPanelPhases.SpaceMemberList:
if (!!cardState?.spaceId || !!roomId) {
card = (
<MemberList
roomId={cardState?.spaceId ?? roomId!}
key={cardState?.spaceId ?? roomId!}
onClose={this.onClose}
searchQuery={this.state.searchQuery}
onSearchQueryChanged={this.onSearchQueryChanged}
/>
);
}
break;
case RightPanelPhases.RoomMemberInfo: case RightPanelPhases.MemberInfo:
case RightPanelPhases.SpaceMemberInfo:
case RightPanelPhases.EncryptionPanel: { case RightPanelPhases.EncryptionPanel: {
if (!!cardState?.member) { if (!!cardState?.member) {
const roomMember = cardState.member instanceof RoomMember ? cardState.member : undefined; const roomMember = cardState.member instanceof RoomMember ? cardState.member : undefined;
@ -203,8 +189,7 @@ export default class RightPanel extends React.Component<Props, IState> {
} }
break; break;
} }
case RightPanelPhases.Room3pidMemberInfo: case RightPanelPhases.ThreePidMemberInfo:
case RightPanelPhases.Space3pidMemberInfo:
if (!!cardState?.memberInfoEvent) { if (!!cardState?.memberInfoEvent) {
card = ( card = (
<ThirdPartyMemberInfo event={cardState.memberInfoEvent} key={roomId} onClose={this.onClose} /> <ThirdPartyMemberInfo event={cardState.memberInfoEvent} key={roomId} onClose={this.onClose} />

View file

@ -1214,18 +1214,18 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
if (payload.member) { if (payload.member) {
if (payload.push) { if (payload.push) {
RightPanelStore.instance.pushCard({ RightPanelStore.instance.pushCard({
phase: RightPanelPhases.RoomMemberInfo, phase: RightPanelPhases.MemberInfo,
state: { member: payload.member }, state: { member: payload.member },
}); });
} else { } else {
RightPanelStore.instance.setCards([ RightPanelStore.instance.setCards([
{ phase: RightPanelPhases.RoomSummary }, { phase: RightPanelPhases.RoomSummary },
{ phase: RightPanelPhases.RoomMemberList }, { phase: RightPanelPhases.MemberList },
{ phase: RightPanelPhases.RoomMemberInfo, state: { member: payload.member } }, { phase: RightPanelPhases.MemberInfo, state: { member: payload.member } },
]); ]);
} }
} else { } else {
RightPanelStore.instance.showOrHidePhase(RightPanelPhases.RoomMemberList); RightPanelStore.instance.showOrHidePhase(RightPanelPhases.MemberList);
} }
break; break;
case Action.View3pidInvite: case Action.View3pidInvite:

View file

@ -208,7 +208,7 @@ const SpaceLanding: React.FC<{ space: Room }> = ({ space }) => {
const storeIsShowingSpaceMembers = useCallback( const storeIsShowingSpaceMembers = useCallback(
() => () =>
RightPanelStore.instance.isOpenForRoom(space.roomId) && RightPanelStore.instance.isOpenForRoom(space.roomId) &&
RightPanelStore.instance.currentCardForRoom(space.roomId)?.phase === RightPanelPhases.SpaceMemberList, RightPanelStore.instance.currentCardForRoom(space.roomId)?.phase === RightPanelPhases.MemberList,
[space.roomId], [space.roomId],
); );
const isShowingMembers = useEventEmitterState(RightPanelStore.instance, UPDATE_EVENT, storeIsShowingSpaceMembers); const isShowingMembers = useEventEmitterState(RightPanelStore.instance, UPDATE_EVENT, storeIsShowingSpaceMembers);
@ -251,7 +251,7 @@ const SpaceLanding: React.FC<{ space: Room }> = ({ space }) => {
} }
const onMembersClick = (): void => { const onMembersClick = (): void => {
RightPanelStore.instance.setCard({ phase: RightPanelPhases.SpaceMemberList }); RightPanelStore.instance.setCard({ phase: RightPanelPhases.MemberList });
}; };
return ( return (

View file

@ -82,7 +82,7 @@ export default class UserView extends React.Component<IProps, IState> {
} else if (this.state.member) { } else if (this.state.member) {
const panel = ( const panel = (
<RightPanel <RightPanel
overwriteCard={{ phase: RightPanelPhases.RoomMemberInfo, state: { member: this.state.member } }} overwriteCard={{ phase: RightPanelPhases.MemberInfo, state: { member: this.state.member } }}
resizeNotifier={this.props.resizeNotifier} resizeNotifier={this.props.resizeNotifier}
/> />
); );

View file

@ -86,7 +86,7 @@ interface IProps {
} }
const onRoomMembersClick = (): void => { const onRoomMembersClick = (): void => {
RightPanelStore.instance.pushCard({ phase: RightPanelPhases.RoomMemberList }, true); RightPanelStore.instance.pushCard({ phase: RightPanelPhases.MemberList }, true);
}; };
const onRoomThreadsClick = (): void => { const onRoomThreadsClick = (): void => {

View file

@ -1739,13 +1739,13 @@ export const UserInfoHeader: React.FC<{
interface IProps { interface IProps {
user: Member; user: Member;
room?: Room; room?: Room;
phase: RightPanelPhases.RoomMemberInfo | RightPanelPhases.SpaceMemberInfo | RightPanelPhases.EncryptionPanel; phase: RightPanelPhases.MemberInfo | RightPanelPhases.MemberInfo | RightPanelPhases.EncryptionPanel;
onClose(): void; onClose(): void;
verificationRequest?: VerificationRequest; verificationRequest?: VerificationRequest;
verificationRequestPromise?: Promise<VerificationRequest>; verificationRequestPromise?: Promise<VerificationRequest>;
} }
const UserInfo: React.FC<IProps> = ({ user, room, onClose, phase = RightPanelPhases.RoomMemberInfo, ...props }) => { const UserInfo: React.FC<IProps> = ({ user, room, onClose, phase = RightPanelPhases.MemberInfo, ...props }) => {
const cli = useContext(MatrixClientContext); const cli = useContext(MatrixClientContext);
// fetch latest room member if we have a room, so we don't show historical information, falling back to user // fetch latest room member if we have a room, so we don't show historical information, falling back to user
@ -1767,8 +1767,6 @@ const UserInfo: React.FC<IProps> = ({ user, room, onClose, phase = RightPanelPha
// We have no previousPhase for when viewing a UserInfo without a Room at this time // We have no previousPhase for when viewing a UserInfo without a Room at this time
if (room && phase === RightPanelPhases.EncryptionPanel) { if (room && phase === RightPanelPhases.EncryptionPanel) {
cardState = { member }; cardState = { member };
} else if (room?.isSpaceRoom()) {
cardState = { spaceId: room.roomId };
} }
const onEncryptionPanelClose = (): void => { const onEncryptionPanelClose = (): void => {
@ -1777,8 +1775,7 @@ const UserInfo: React.FC<IProps> = ({ user, room, onClose, phase = RightPanelPha
let content: JSX.Element | undefined; let content: JSX.Element | undefined;
switch (phase) { switch (phase) {
case RightPanelPhases.RoomMemberInfo: case RightPanelPhases.MemberInfo:
case RightPanelPhases.SpaceMemberInfo:
content = ( content = (
<BasicUserInfo <BasicUserInfo
room={room as Room} room={room as Room}
@ -1823,7 +1820,7 @@ const UserInfo: React.FC<IProps> = ({ user, room, onClose, phase = RightPanelPha
closeLabel={closeLabel} closeLabel={closeLabel}
cardState={cardState} cardState={cardState}
onBack={(ev: ButtonEvent) => { onBack={(ev: ButtonEvent) => {
if (RightPanelStore.instance.previousCard.phase === RightPanelPhases.RoomMemberList) { if (RightPanelStore.instance.previousCard.phase === RightPanelPhases.MemberList) {
PosthogTrackers.trackInteraction("WebRightPanelRoomUserInfoBackButton", ev); PosthogTrackers.trackInteraction("WebRightPanelRoomUserInfoBackButton", ev);
} }
}} }}

View file

@ -392,7 +392,7 @@ export default function RoomHeader({
viewUserOnClick={false} viewUserOnClick={false}
tooltipLabel={_t("room|header_face_pile_tooltip")} tooltipLabel={_t("room|header_face_pile_tooltip")}
onClick={(e: ButtonEvent) => { onClick={(e: ButtonEvent) => {
RightPanelStore.instance.showOrHidePhase(RightPanelPhases.RoomMemberList); RightPanelStore.instance.showOrHidePhase(RightPanelPhases.MemberList);
e.stopPropagation(); e.stopPropagation();
}} }}
aria-label={_t("common|n_members", { count: memberCount })} aria-label={_t("common|n_members", { count: memberCount })}

View file

@ -64,7 +64,7 @@ const RoomInfoLine: FC<IProps> = ({ room }) => {
// summary is not still loading // summary is not still loading
const viewMembers = (): void => const viewMembers = (): void =>
RightPanelStore.instance.setCard({ RightPanelStore.instance.setCard({
phase: room.isSpaceRoom() ? RightPanelPhases.SpaceMemberList : RightPanelPhases.RoomMemberList, phase: RightPanelPhases.MemberList,
}); });
members = ( members = (

View file

@ -117,7 +117,7 @@ export default class VerificationRequestToast extends React.PureComponent<IProps
RightPanelStore.instance.setCards( RightPanelStore.instance.setCards(
[ [
{ phase: RightPanelPhases.RoomSummary }, { phase: RightPanelPhases.RoomSummary },
{ phase: RightPanelPhases.RoomMemberInfo, state: { member } }, { phase: RightPanelPhases.MemberInfo, state: { member } },
{ phase: RightPanelPhases.EncryptionPanel, state: { verificationRequest: request, member } }, { phase: RightPanelPhases.EncryptionPanel, state: { verificationRequest: request, member } },
], ],
undefined, undefined,

View file

@ -304,15 +304,15 @@ export default class RightPanelStore extends ReadyWatchingStore {
logger.warn("removed card from right panel because of missing threadHeadEvent in card state"); logger.warn("removed card from right panel because of missing threadHeadEvent in card state");
} }
return !!card.state?.threadHeadEvent; return !!card.state?.threadHeadEvent;
case RightPanelPhases.RoomMemberInfo: case RightPanelPhases.MemberInfo:
case RightPanelPhases.SpaceMemberInfo: case RightPanelPhases.MemberInfo:
case RightPanelPhases.EncryptionPanel: case RightPanelPhases.EncryptionPanel:
if (!card.state?.member) { if (!card.state?.member) {
logger.warn("removed card from right panel because of missing member in card state"); logger.warn("removed card from right panel because of missing member in card state");
} }
return !!card.state?.member; return !!card.state?.member;
case RightPanelPhases.Room3pidMemberInfo: case RightPanelPhases.ThreePidMemberInfo:
case RightPanelPhases.Space3pidMemberInfo: case RightPanelPhases.ThreePidMemberInfo:
if (!card.state?.memberInfoEvent) { if (!card.state?.memberInfoEvent) {
logger.warn("removed card from right panel because of missing memberInfoEvent in card state"); logger.warn("removed card from right panel because of missing memberInfoEvent in card state");
} }
@ -327,7 +327,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
} }
private getVerificationRedirect(card: IRightPanelCard): IRightPanelCard | null { private getVerificationRedirect(card: IRightPanelCard): IRightPanelCard | null {
if (card.phase === RightPanelPhases.RoomMemberInfo && card.state) { if (card.phase === RightPanelPhases.MemberInfo && card.state) {
// RightPanelPhases.RoomMemberInfo -> needs to be changed to RightPanelPhases.EncryptionPanel if there is a pending verification request // RightPanelPhases.RoomMemberInfo -> needs to be changed to RightPanelPhases.EncryptionPanel if there is a pending verification request
const { member } = card.state; const { member } = card.state;
const pendingRequest = member const pendingRequest = member
@ -385,8 +385,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
if (panel?.history) { if (panel?.history) {
panel.history = panel.history.filter( panel.history = panel.history.filter(
(card: IRightPanelCard) => (card: IRightPanelCard) =>
card.phase != RightPanelPhases.RoomMemberInfo && card.phase != RightPanelPhases.MemberInfo && card.phase != RightPanelPhases.ThreePidMemberInfo,
card.phase != RightPanelPhases.Room3pidMemberInfo,
); );
} }
} }

View file

@ -16,7 +16,6 @@ export interface IRightPanelCardState {
verificationRequest?: VerificationRequest; verificationRequest?: VerificationRequest;
verificationRequestPromise?: Promise<VerificationRequest>; verificationRequestPromise?: Promise<VerificationRequest>;
widgetId?: string; widgetId?: string;
spaceId?: string;
// Room3pidMemberInfo, Space3pidMemberInfo, // Room3pidMemberInfo, Space3pidMemberInfo,
memberInfoEvent?: MatrixEvent; memberInfoEvent?: MatrixEvent;
// threads // threads
@ -32,7 +31,6 @@ export interface IRightPanelCardStateStored {
memberId?: string; memberId?: string;
// we do not store the things associated with verification // we do not store the things associated with verification
widgetId?: string; widgetId?: string;
spaceId?: string;
// 3pidMemberInfo // 3pidMemberInfo
memberInfoEventId?: string; memberInfoEventId?: string;
// threads // threads
@ -80,7 +78,6 @@ export function convertCardToStore(panelState: IRightPanelCard): IRightPanelCard
const state = panelState.state ?? {}; const state = panelState.state ?? {};
const stateStored: IRightPanelCardStateStored = { const stateStored: IRightPanelCardStateStored = {
widgetId: state.widgetId, widgetId: state.widgetId,
spaceId: state.spaceId,
isInitialEventHighlighted: state.isInitialEventHighlighted, isInitialEventHighlighted: state.isInitialEventHighlighted,
initialEventScrollIntoView: state.initialEventScrollIntoView, initialEventScrollIntoView: state.initialEventScrollIntoView,
threadHeadEventId: !!state?.threadHeadEvent?.getId() ? state.threadHeadEvent.getId() : undefined, threadHeadEventId: !!state?.threadHeadEvent?.getId() ? state.threadHeadEvent.getId() : undefined,
@ -97,7 +94,6 @@ function convertStoreToCard(panelStateStore: IRightPanelCardStored, room: Room):
const stateStored = panelStateStore.state ?? {}; const stateStored = panelStateStore.state ?? {};
const state: IRightPanelCardState = { const state: IRightPanelCardState = {
widgetId: stateStored.widgetId, widgetId: stateStored.widgetId,
spaceId: stateStored.spaceId,
isInitialEventHighlighted: stateStored.isInitialEventHighlighted, isInitialEventHighlighted: stateStored.isInitialEventHighlighted,
initialEventScrollIntoView: stateStored.initialEventScrollIntoView, initialEventScrollIntoView: stateStored.initialEventScrollIntoView,
threadHeadEvent: !!stateStored?.threadHeadEventId threadHeadEvent: !!stateStored?.threadHeadEventId

View file

@ -10,11 +10,14 @@ import { _t } from "../../languageHandler";
// These are in their own file because of circular imports being a problem. // These are in their own file because of circular imports being a problem.
export enum RightPanelPhases { export enum RightPanelPhases {
// Room & Space stuff
MemberList = "MemberList",
MemberInfo = "MemberInfo",
ThreePidMemberInfo = "ThreePidMemberInfo",
// Room stuff // Room stuff
RoomMemberList = "RoomMemberList",
FilePanel = "FilePanel", FilePanel = "FilePanel",
NotificationPanel = "NotificationPanel", NotificationPanel = "NotificationPanel",
RoomMemberInfo = "RoomMemberInfo",
EncryptionPanel = "EncryptionPanel", EncryptionPanel = "EncryptionPanel",
RoomSummary = "RoomSummary", RoomSummary = "RoomSummary",
Widget = "Widget", Widget = "Widget",
@ -22,13 +25,6 @@ export enum RightPanelPhases {
Timeline = "Timeline", Timeline = "Timeline",
Extensions = "Extensions", Extensions = "Extensions",
Room3pidMemberInfo = "Room3pidMemberInfo",
// Space stuff
SpaceMemberList = "SpaceMemberList",
SpaceMemberInfo = "SpaceMemberInfo",
Space3pidMemberInfo = "Space3pidMemberInfo",
// Thread stuff // Thread stuff
ThreadView = "ThreadView", ThreadView = "ThreadView",
ThreadPanel = "ThreadPanel", ThreadPanel = "ThreadPanel",
@ -42,7 +38,7 @@ export function backLabelForPhase(phase: RightPanelPhases | null): string | null
return _t("chat_card_back_action_label"); return _t("chat_card_back_action_label");
case RightPanelPhases.RoomSummary: case RightPanelPhases.RoomSummary:
return _t("room_summary_card_back_action_label"); return _t("room_summary_card_back_action_label");
case RightPanelPhases.RoomMemberList: case RightPanelPhases.MemberList:
return _t("member_list_back_action_label"); return _t("member_list_back_action_label");
case RightPanelPhases.ThreadView: case RightPanelPhases.ThreadView:
return _t("thread_view_back_action_label"); return _t("thread_view_back_action_label");

View file

@ -20,10 +20,10 @@ import { RightPanelPhases } from "../RightPanelStorePhases";
export const onView3pidInvite = (payload: ActionPayload, rightPanelStore: RightPanelStore): void => { export const onView3pidInvite = (payload: ActionPayload, rightPanelStore: RightPanelStore): void => {
if (payload.event) { if (payload.event) {
rightPanelStore.pushCard({ rightPanelStore.pushCard({
phase: RightPanelPhases.Room3pidMemberInfo, phase: RightPanelPhases.ThreePidMemberInfo,
state: { memberInfoEvent: payload.event }, state: { memberInfoEvent: payload.event },
}); });
} else { } else {
rightPanelStore.showOrHidePhase(RightPanelPhases.RoomMemberList); rightPanelStore.showOrHidePhase(RightPanelPhases.MemberList);
} }
}; };

View file

@ -81,7 +81,7 @@ function setRightPanel(state: IRightPanelCardState): void {
} else { } else {
RightPanelStore.instance.setCards([ RightPanelStore.instance.setCards([
{ phase: RightPanelPhases.RoomSummary }, { phase: RightPanelPhases.RoomSummary },
{ phase: RightPanelPhases.RoomMemberInfo, state: { member: state.member } }, { phase: RightPanelPhases.MemberInfo, state: { member: state.member } },
{ phase: RightPanelPhases.EncryptionPanel, state }, { phase: RightPanelPhases.EncryptionPanel, state },
]); ]);
} }

View file

@ -91,7 +91,7 @@ describe("RightPanel", () => {
if (name !== "RightPanel.phases") return realGetValue(name, roomId); if (name !== "RightPanel.phases") return realGetValue(name, roomId);
if (roomId === "r1") { if (roomId === "r1") {
return { return {
history: [{ phase: RightPanelPhases.RoomMemberList }], history: [{ phase: RightPanelPhases.MemberList }],
isOpen: true, isOpen: true,
}; };
} }
@ -123,7 +123,7 @@ describe("RightPanel", () => {
await rpsUpdated; await rpsUpdated;
await waitFor(() => expect(screen.queryByTestId("spinner")).not.toBeInTheDocument()); await waitFor(() => expect(screen.queryByTestId("spinner")).not.toBeInTheDocument());
// room one will be in the RoomMemberList phase - confirm this is rendered // room one will be in the MemberList phase - confirm this is rendered
expect(container.getElementsByClassName("mx_MemberList")).toHaveLength(1); expect(container.getElementsByClassName("mx_MemberList")).toHaveLength(1);
// wait for RPS room 2 updates to fire, then rerender // wait for RPS room 2 updates to fire, then rerender

View file

@ -254,10 +254,7 @@ describe("<RoomSummaryCard />", () => {
fireEvent.click(getByText("People")); fireEvent.click(getByText("People"));
expect(RightPanelStore.instance.pushCard).toHaveBeenCalledWith( expect(RightPanelStore.instance.pushCard).toHaveBeenCalledWith({ phase: RightPanelPhases.MemberList }, true);
{ phase: RightPanelPhases.RoomMemberList },
true,
);
}); });
it("opens room threads list on button click", () => { it("opens room threads list on button click", () => {

View file

@ -188,7 +188,7 @@ describe("<UserInfo />", () => {
const defaultProps = { const defaultProps = {
user: defaultUser, user: defaultUser,
// idk what is wrong with this type // idk what is wrong with this type
phase: RightPanelPhases.RoomMemberInfo as RightPanelPhases.RoomMemberInfo, phase: RightPanelPhases.MemberInfo as RightPanelPhases.MemberInfo,
onClose: jest.fn(), onClose: jest.fn(),
}; };
@ -455,7 +455,7 @@ describe("<UserInfo />", () => {
mockCrypto.getUserVerificationStatus.mockResolvedValue(new UserVerificationStatus(false, false, false)); mockCrypto.getUserVerificationStatus.mockResolvedValue(new UserVerificationStatus(false, false, false));
const { container } = renderComponent({ const { container } = renderComponent({
phase: RightPanelPhases.SpaceMemberInfo, phase: RightPanelPhases.MemberInfo,
verificationRequest, verificationRequest,
room: mockRoom, room: mockRoom,
}); });
@ -649,7 +649,7 @@ describe("<UserInfo />", () => {
mockClient.getDomain.mockReturnValue("example.com"); mockClient.getDomain.mockReturnValue("example.com");
const { container } = renderComponent({ const { container } = renderComponent({
phase: RightPanelPhases.RoomMemberInfo, phase: RightPanelPhases.MemberInfo,
room: mockRoom, room: mockRoom,
}); });

View file

@ -224,7 +224,7 @@ describe("<PinnedMessageBanner />", () => {
// The Right panel is opened on another card // The Right panel is opened on another card
jest.spyOn(RightPanelStore.instance, "isOpenForRoom").mockReturnValue(true); jest.spyOn(RightPanelStore.instance, "isOpenForRoom").mockReturnValue(true);
jest.spyOn(RightPanelStore.instance, "currentCard", "get").mockReturnValue({ jest.spyOn(RightPanelStore.instance, "currentCard", "get").mockReturnValue({
phase: RightPanelPhases.RoomMemberList, phase: RightPanelPhases.MemberList,
}); });
renderBanner(); renderBanner();

View file

@ -158,7 +158,7 @@ describe("RoomHeader", () => {
fireEvent.click(facePile); fireEvent.click(facePile);
expect(setCardSpy).toHaveBeenCalledWith({ phase: RightPanelPhases.RoomMemberList }); expect(setCardSpy).toHaveBeenCalledWith({ phase: RightPanelPhases.MemberList });
}); });
it("has room info icon that opens the room info panel", async () => { it("has room info icon that opens the room info panel", async () => {

View file

@ -97,7 +97,7 @@ describe("RightPanelStore", () => {
it("does nothing if given an invalid state", async () => { it("does nothing if given an invalid state", async () => {
await viewRoom("!1:example.org"); await viewRoom("!1:example.org");
// Needs a member specified to be valid // Needs a member specified to be valid
store.setCard({ phase: RightPanelPhases.RoomMemberInfo }, true, "!1:example.org"); store.setCard({ phase: RightPanelPhases.MemberInfo }, true, "!1:example.org");
expect(store.roomPhaseHistory).toEqual([]); expect(store.roomPhaseHistory).toEqual([]);
}); });
it("only creates a single history entry if given the same card twice", async () => { it("only creates a single history entry if given the same card twice", async () => {
@ -114,15 +114,15 @@ describe("RightPanelStore", () => {
it("overwrites history if changing the phase", async () => { it("overwrites history if changing the phase", async () => {
await viewRoom("!1:example.org"); await viewRoom("!1:example.org");
store.setCard({ phase: RightPanelPhases.RoomSummary }, true, "!1:example.org"); store.setCard({ phase: RightPanelPhases.RoomSummary }, true, "!1:example.org");
store.setCard({ phase: RightPanelPhases.RoomMemberList }, true, "!1:example.org"); store.setCard({ phase: RightPanelPhases.MemberList }, true, "!1:example.org");
expect(store.roomPhaseHistory).toEqual([{ phase: RightPanelPhases.RoomMemberList, state: {} }]); expect(store.roomPhaseHistory).toEqual([{ phase: RightPanelPhases.MemberList, state: {} }]);
}); });
}); });
describe("setCards", () => { describe("setCards", () => {
it("overwrites history", async () => { it("overwrites history", async () => {
await viewRoom("!1:example.org"); await viewRoom("!1:example.org");
store.setCard({ phase: RightPanelPhases.RoomMemberList }, true, "!1:example.org"); store.setCard({ phase: RightPanelPhases.MemberList }, true, "!1:example.org");
store.setCards( store.setCards(
[{ phase: RightPanelPhases.RoomSummary }, { phase: RightPanelPhases.PinnedMessages }], [{ phase: RightPanelPhases.RoomSummary }, { phase: RightPanelPhases.PinnedMessages }],
true, true,
@ -200,21 +200,21 @@ describe("RightPanelStore", () => {
store.setCards( store.setCards(
[ [
{ {
phase: RightPanelPhases.RoomMemberList, phase: RightPanelPhases.MemberList,
}, },
{ {
phase: RightPanelPhases.RoomMemberInfo, phase: RightPanelPhases.MemberInfo,
state: { member: new RoomMember("!1:example.org", "@alice:example.org") }, state: { member: new RoomMember("!1:example.org", "@alice:example.org") },
}, },
], ],
true, true,
"!1:example.org", "!1:example.org",
); );
expect(store.currentCardForRoom("!1:example.org").phase).toEqual(RightPanelPhases.RoomMemberInfo); expect(store.currentCardForRoom("!1:example.org").phase).toEqual(RightPanelPhases.MemberInfo);
// Switch away and back // Switch away and back
await viewRoom("!2:example.org"); await viewRoom("!2:example.org");
await viewRoom("!1:example.org"); await viewRoom("!1:example.org");
expect(store.currentCardForRoom("!1:example.org").phase).toEqual(RightPanelPhases.RoomMemberList); expect(store.currentCardForRoom("!1:example.org").phase).toEqual(RightPanelPhases.MemberList);
}); });
}); });

View file

@ -30,7 +30,7 @@ describe("onView3pidInvite()", () => {
}; };
onView3pidInvite(payload, rightPanelStore); onView3pidInvite(payload, rightPanelStore);
expect(rightPanelStore.showOrHidePhase).toHaveBeenCalledWith(RightPanelPhases.RoomMemberList); expect(rightPanelStore.showOrHidePhase).toHaveBeenCalledWith(RightPanelPhases.MemberList);
expect(rightPanelStore.pushCard).not.toHaveBeenCalled(); expect(rightPanelStore.pushCard).not.toHaveBeenCalled();
}); });
@ -43,7 +43,7 @@ describe("onView3pidInvite()", () => {
expect(rightPanelStore.showOrHidePhase).not.toHaveBeenCalled(); expect(rightPanelStore.showOrHidePhase).not.toHaveBeenCalled();
expect(rightPanelStore.pushCard).toHaveBeenCalledWith({ expect(rightPanelStore.pushCard).toHaveBeenCalledWith({
phase: RightPanelPhases.Room3pidMemberInfo, phase: RightPanelPhases.ThreePidMemberInfo,
state: { memberInfoEvent: payload.event }, state: { memberInfoEvent: payload.event },
}); });
}); });