Right panel store refactor (#7313)
Co-authored-by: J. Ryan Stinnett <jryans@gmail.com>
This commit is contained in:
parent
8e881336ab
commit
325e2ba99b
42 changed files with 765 additions and 811 deletions
|
@ -102,16 +102,6 @@ export enum Action {
|
|||
*/
|
||||
ViewRoomDelta = "view_room_delta",
|
||||
|
||||
/**
|
||||
* Sets the phase for the right panel. Should be used with SetRightPanelPhasePayload.
|
||||
*/
|
||||
SetRightPanelPhase = "set_right_panel_phase",
|
||||
|
||||
/**
|
||||
* Toggles the right panel. Should be used with ToggleRightPanelPayload.
|
||||
*/
|
||||
ToggleRightPanel = "toggle_right_panel",
|
||||
|
||||
/**
|
||||
* Trigged after the phase of the right panel is set. Should be used with AfterRightPanelPhaseChangePayload.
|
||||
*/
|
||||
|
|
|
@ -15,31 +15,26 @@ limitations under the License.
|
|||
*/
|
||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||
|
||||
import { RightPanelPhases } from "../../stores/RightPanelStorePhases";
|
||||
import { Action } from "../actions";
|
||||
import dis from '../dispatcher';
|
||||
import { SetRightPanelPhasePayload } from "../payloads/SetRightPanelPhasePayload";
|
||||
import RightPanelStore from "../../stores/right-panel/RightPanelStore";
|
||||
import { RightPanelPhases } from "../../stores/right-panel/RightPanelStorePhases";
|
||||
|
||||
export const dispatchShowThreadEvent = (
|
||||
rootEvent: MatrixEvent,
|
||||
initialEvent?: MatrixEvent,
|
||||
highlighted?: boolean,
|
||||
) => {
|
||||
dis.dispatch({
|
||||
action: Action.SetRightPanelPhase,
|
||||
// TODO RightPanelStore (will be addressed in a follow up PR): this should really be a push!
|
||||
RightPanelStore.instance.setCard({
|
||||
phase: RightPanelPhases.ThreadView,
|
||||
refireParams: {
|
||||
event: rootEvent,
|
||||
state: {
|
||||
threadHeadEvent: rootEvent,
|
||||
initialEvent,
|
||||
highlighted,
|
||||
isInitialEventHighlighted: highlighted,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const dispatchShowThreadsPanelEvent = () => {
|
||||
dis.dispatch<SetRightPanelPhasePayload>({
|
||||
action: Action.SetRightPanelPhase,
|
||||
phase: RightPanelPhases.ThreadPanel,
|
||||
});
|
||||
RightPanelStore.instance.setCard({ phase: RightPanelPhases.ThreadPanel });
|
||||
};
|
||||
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||
|
||||
import { RightPanelPhases } from "../../stores/RightPanelStorePhases";
|
||||
import { SetRightPanelPhaseRefireParams } from "./SetRightPanelPhasePayload";
|
||||
import { ActionPayload } from "../payloads";
|
||||
import { Action } from "../actions";
|
||||
|
||||
interface AfterRightPanelPhaseChangeAction extends ActionPayload {
|
||||
action: Action.AfterRightPanelPhaseChange;
|
||||
phase: RightPanelPhases;
|
||||
verificationRequestPromise?: Promise<VerificationRequest>;
|
||||
}
|
||||
|
||||
export type AfterRightPanelPhaseChangePayload
|
||||
= AfterRightPanelPhaseChangeAction & SetRightPanelPhaseRefireParams;
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||
import { User } from "matrix-js-sdk/src/models/user";
|
||||
|
||||
import { RightPanelPhases } from "../../stores/RightPanelStorePhases";
|
||||
import { ActionPayload } from "../payloads";
|
||||
import { Action } from "../actions";
|
||||
|
||||
export interface SetRightPanelPhasePayload extends ActionPayload {
|
||||
action: Action.SetRightPanelPhase;
|
||||
|
||||
phase: RightPanelPhases;
|
||||
refireParams?: SetRightPanelPhaseRefireParams;
|
||||
|
||||
/**
|
||||
* By default SetRightPanelPhase can close the panel, this allows overriding that behaviour
|
||||
*/
|
||||
allowClose?: boolean;
|
||||
}
|
||||
|
||||
export interface SetRightPanelPhaseRefireParams {
|
||||
member?: RoomMember | User;
|
||||
verificationRequest?: VerificationRequest;
|
||||
groupId?: string;
|
||||
groupRoomId?: string;
|
||||
// XXX: The type for event should 'view_3pid_invite' action's payload
|
||||
event?: any;
|
||||
widgetId?: string;
|
||||
space?: Room;
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { ActionPayload } from "../payloads";
|
||||
import { Action } from "../actions";
|
||||
|
||||
export interface ToggleRightPanelPayload extends ActionPayload {
|
||||
action: Action.ToggleRightPanel;
|
||||
|
||||
/**
|
||||
* The type of room that the panel is toggled in.
|
||||
*/
|
||||
type: "group" | "room";
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue