do the todos
This commit is contained in:
parent
4a4a8cd611
commit
8d14d26e2b
5 changed files with 45 additions and 35 deletions
|
@ -25,6 +25,7 @@ import HeaderButtons, {HeaderKind} from './HeaderButtons';
|
|||
import {RightPanelPhases} from "../../../stores/RightPanelStorePhases";
|
||||
import {Action} from "../../../dispatcher/actions";
|
||||
import {ActionPayload} from "../../../dispatcher/payloads";
|
||||
import RightPanelStore from "../../../stores/RightPanelStore";
|
||||
|
||||
const ROOM_INFO_PHASES = [
|
||||
RightPanelPhases.RoomSummary,
|
||||
|
@ -57,11 +58,15 @@ export default class RoomHeaderButtons extends HeaderButtons {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO make it restore whatever widget they were on last
|
||||
private onRoomSummaryClicked = () => {
|
||||
if (this.state.phase === RightPanelPhases.Widget) {
|
||||
// Close the panel
|
||||
this.setPhase(RightPanelPhases.Widget);
|
||||
// use roomPanelPhase rather than this.state.phase as it remembers the latest one if we close
|
||||
const lastPhase = RightPanelStore.getSharedInstance().roomPanelPhase;
|
||||
if (ROOM_INFO_PHASES.includes(lastPhase)) {
|
||||
if (this.state.phase === lastPhase) {
|
||||
this.setPhase(lastPhase);
|
||||
} else {
|
||||
this.setPhase(lastPhase, RightPanelStore.getSharedInstance().roomPanelPhaseParams);
|
||||
}
|
||||
} else {
|
||||
// This toggles for us, if needed
|
||||
this.setPhase(RightPanelPhases.RoomSummary);
|
||||
|
|
|
@ -46,13 +46,6 @@ interface IProps {
|
|||
onClose(): void;
|
||||
}
|
||||
|
||||
const onFinished = () => {
|
||||
defaultDispatcher.dispatch<SetRightPanelPhasePayload>({
|
||||
action: Action.SetRightPanelPhase,
|
||||
phase: RightPanelPhases.RoomSummary,
|
||||
});
|
||||
}
|
||||
|
||||
const WidgetCard: React.FC<IProps> = ({ room, widgetId, onClose }) => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
|
||||
|
@ -64,8 +57,11 @@ const WidgetCard: React.FC<IProps> = ({ room, widgetId, onClose }) => {
|
|||
|
||||
useEffect(() => {
|
||||
if (!app || isPinned) {
|
||||
// TODO maybe we should do this in the ActiveWidgetStore instead
|
||||
onFinished();
|
||||
// stop showing this card
|
||||
defaultDispatcher.dispatch<SetRightPanelPhasePayload>({
|
||||
action: Action.SetRightPanelPhase,
|
||||
phase: RightPanelPhases.RoomSummary,
|
||||
});
|
||||
}
|
||||
}, [app, isPinned]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue