Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -23,14 +23,14 @@ import classNames from "classnames";
|
|||
import { NotificationCountType, Room, RoomEvent } from "matrix-js-sdk/src/models/room";
|
||||
import { Feature, ServerSupport } from "matrix-js-sdk/src/feature";
|
||||
|
||||
import { _t } from '../../../languageHandler';
|
||||
import HeaderButton from './HeaderButton';
|
||||
import HeaderButtons, { HeaderKind } from './HeaderButtons';
|
||||
import { RightPanelPhases } from '../../../stores/right-panel/RightPanelStorePhases';
|
||||
import { _t } from "../../../languageHandler";
|
||||
import HeaderButton from "./HeaderButton";
|
||||
import HeaderButtons, { HeaderKind } from "./HeaderButtons";
|
||||
import { RightPanelPhases } from "../../../stores/right-panel/RightPanelStorePhases";
|
||||
import { Action } from "../../../dispatcher/actions";
|
||||
import { ActionPayload } from "../../../dispatcher/payloads";
|
||||
import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
|
||||
import { useReadPinnedEvents, usePinnedEvents } from './PinnedMessagesCard';
|
||||
import { useReadPinnedEvents, usePinnedEvents } from "./PinnedMessagesCard";
|
||||
import { showThreadPanel } from "../../../dispatcher/dispatch-actions/threads";
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
import {
|
||||
|
@ -65,16 +65,18 @@ const UnreadIndicator = ({ color }: IUnreadIndicatorProps) => {
|
|||
}
|
||||
|
||||
const classes = classNames({
|
||||
"mx_Indicator": true,
|
||||
"mx_RightPanel_headerButton_unreadIndicator": true,
|
||||
"mx_Indicator_bold": color === NotificationColor.Bold,
|
||||
"mx_Indicator_gray": color === NotificationColor.Grey,
|
||||
"mx_Indicator_red": color === NotificationColor.Red,
|
||||
mx_Indicator: true,
|
||||
mx_RightPanel_headerButton_unreadIndicator: true,
|
||||
mx_Indicator_bold: color === NotificationColor.Bold,
|
||||
mx_Indicator_gray: color === NotificationColor.Grey,
|
||||
mx_Indicator_red: color === NotificationColor.Red,
|
||||
});
|
||||
return <>
|
||||
<div className="mx_RightPanel_headerButton_unreadIndicator_bg" />
|
||||
<div className={classes} />
|
||||
</>;
|
||||
return (
|
||||
<>
|
||||
<div className="mx_RightPanel_headerButton_unreadIndicator_bg" />
|
||||
<div className={classes} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
interface IHeaderButtonProps {
|
||||
|
@ -89,19 +91,21 @@ const PinnedMessagesHeaderButton = ({ room, isHighlighted, onClick }: IHeaderBut
|
|||
if (!pinnedEvents?.length) return null;
|
||||
|
||||
let unreadIndicator;
|
||||
if (pinnedEvents.some(id => !readPinnedEvents.has(id))) {
|
||||
if (pinnedEvents.some((id) => !readPinnedEvents.has(id))) {
|
||||
unreadIndicator = <UnreadIndicator />;
|
||||
}
|
||||
|
||||
return <HeaderButton
|
||||
name="pinnedMessagesButton"
|
||||
title={_t("Pinned messages")}
|
||||
isHighlighted={isHighlighted}
|
||||
isUnread={!!unreadIndicator}
|
||||
onClick={onClick}
|
||||
>
|
||||
{ unreadIndicator }
|
||||
</HeaderButton>;
|
||||
return (
|
||||
<HeaderButton
|
||||
name="pinnedMessagesButton"
|
||||
title={_t("Pinned messages")}
|
||||
isHighlighted={isHighlighted}
|
||||
isUnread={!!unreadIndicator}
|
||||
onClick={onClick}
|
||||
>
|
||||
{unreadIndicator}
|
||||
</HeaderButton>
|
||||
);
|
||||
};
|
||||
|
||||
const TimelineCardHeaderButton = ({ room, isHighlighted, onClick }: IHeaderButtonProps) => {
|
||||
|
@ -113,14 +117,11 @@ const TimelineCardHeaderButton = ({ room, isHighlighted, onClick }: IHeaderButto
|
|||
case NotificationColor.Red:
|
||||
unreadIndicator = <UnreadIndicator color={color} />;
|
||||
}
|
||||
return <HeaderButton
|
||||
name="timelineCardButton"
|
||||
title={_t("Chat")}
|
||||
isHighlighted={isHighlighted}
|
||||
onClick={onClick}
|
||||
>
|
||||
{ unreadIndicator }
|
||||
</HeaderButton>;
|
||||
return (
|
||||
<HeaderButton name="timelineCardButton" title={_t("Chat")} isHighlighted={isHighlighted} onClick={onClick}>
|
||||
{unreadIndicator}
|
||||
</HeaderButton>
|
||||
);
|
||||
};
|
||||
|
||||
interface IProps {
|
||||
|
@ -129,10 +130,7 @@ interface IProps {
|
|||
}
|
||||
|
||||
export default class RoomHeaderButtons extends HeaderButtons<IProps> {
|
||||
private static readonly THREAD_PHASES = [
|
||||
RightPanelPhases.ThreadPanel,
|
||||
RightPanelPhases.ThreadView,
|
||||
];
|
||||
private static readonly THREAD_PHASES = [RightPanelPhases.ThreadPanel, RightPanelPhases.ThreadView];
|
||||
private threadNotificationState: ThreadsRoomNotificationState | null;
|
||||
private globalNotificationState: SummarizedNotificationState;
|
||||
|
||||
|
@ -144,9 +142,10 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
|
|||
constructor(props: IProps) {
|
||||
super(props, HeaderKind.Room);
|
||||
|
||||
this.threadNotificationState = !this.supportsThreadNotifications && this.props.room
|
||||
? RoomNotificationStateStore.instance.getThreadsRoomState(this.props.room)
|
||||
: null;
|
||||
this.threadNotificationState =
|
||||
!this.supportsThreadNotifications && this.props.room
|
||||
? RoomNotificationStateStore.instance.getThreadsRoomState(this.props.room)
|
||||
: null;
|
||||
this.globalNotificationState = RoomNotificationStateStore.instance.globalState;
|
||||
}
|
||||
|
||||
|
@ -209,9 +208,10 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
|
|||
if (payload.action === Action.ViewUser) {
|
||||
if (payload.member) {
|
||||
if (payload.push) {
|
||||
RightPanelStore.instance.pushCard(
|
||||
{ phase: RightPanelPhases.RoomMemberInfo, state: { member: payload.member } },
|
||||
);
|
||||
RightPanelStore.instance.pushCard({
|
||||
phase: RightPanelPhases.RoomMemberInfo,
|
||||
state: { member: payload.member },
|
||||
});
|
||||
} else {
|
||||
RightPanelStore.instance.setCards([
|
||||
{ phase: RightPanelPhases.RoomSummary },
|
||||
|
@ -276,24 +276,29 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
|
|||
const rightPanelPhaseButtons: Map<RightPanelPhases, any> = new Map();
|
||||
|
||||
if (SettingsStore.getValue("feature_pinning")) {
|
||||
rightPanelPhaseButtons.set(RightPanelPhases.PinnedMessages,
|
||||
rightPanelPhaseButtons.set(
|
||||
RightPanelPhases.PinnedMessages,
|
||||
<PinnedMessagesHeaderButton
|
||||
key="pinnedMessagesButton"
|
||||
room={this.props.room}
|
||||
isHighlighted={this.isPhase(RightPanelPhases.PinnedMessages)}
|
||||
onClick={this.onPinnedMessagesClicked} />,
|
||||
onClick={this.onPinnedMessagesClicked}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
rightPanelPhaseButtons.set(RightPanelPhases.Timeline,
|
||||
rightPanelPhaseButtons.set(
|
||||
RightPanelPhases.Timeline,
|
||||
<TimelineCardHeaderButton
|
||||
key="timelineButton"
|
||||
room={this.props.room}
|
||||
isHighlighted={this.isPhase(RightPanelPhases.Timeline)}
|
||||
onClick={this.onTimelineCardClicked} />,
|
||||
onClick={this.onTimelineCardClicked}
|
||||
/>,
|
||||
);
|
||||
rightPanelPhaseButtons.set(RightPanelPhases.ThreadPanel,
|
||||
SettingsStore.getValue("feature_thread")
|
||||
? <HeaderButton
|
||||
rightPanelPhaseButtons.set(
|
||||
RightPanelPhases.ThreadPanel,
|
||||
SettingsStore.getValue("feature_thread") ? (
|
||||
<HeaderButton
|
||||
key={RightPanelPhases.ThreadPanel}
|
||||
name="threadsButton"
|
||||
data-testid="threadsButton"
|
||||
|
@ -304,39 +309,42 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
|
|||
>
|
||||
<UnreadIndicator color={this.state.threadNotificationColor} />
|
||||
</HeaderButton>
|
||||
: null,
|
||||
) : null,
|
||||
);
|
||||
rightPanelPhaseButtons.set(RightPanelPhases.NotificationPanel,
|
||||
rightPanelPhaseButtons.set(
|
||||
RightPanelPhases.NotificationPanel,
|
||||
<HeaderButton
|
||||
key="notifsButton"
|
||||
name="notifsButton"
|
||||
title={_t('Notifications')}
|
||||
title={_t("Notifications")}
|
||||
isHighlighted={this.isPhase(RightPanelPhases.NotificationPanel)}
|
||||
onClick={this.onNotificationsClicked}
|
||||
isUnread={this.globalNotificationState.color === NotificationColor.Red}
|
||||
>
|
||||
{ this.globalNotificationState.color === NotificationColor.Red ?
|
||||
<UnreadIndicator color={this.globalNotificationState.color} /> :
|
||||
null }
|
||||
{this.globalNotificationState.color === NotificationColor.Red ? (
|
||||
<UnreadIndicator color={this.globalNotificationState.color} />
|
||||
) : null}
|
||||
</HeaderButton>,
|
||||
);
|
||||
rightPanelPhaseButtons.set(RightPanelPhases.RoomSummary,
|
||||
rightPanelPhaseButtons.set(
|
||||
RightPanelPhases.RoomSummary,
|
||||
<HeaderButton
|
||||
key="roomSummaryButton"
|
||||
name="roomSummaryButton"
|
||||
title={_t('Room info')}
|
||||
title={_t("Room info")}
|
||||
isHighlighted={this.isPhase(ROOM_INFO_PHASES)}
|
||||
onClick={this.onRoomSummaryClicked}
|
||||
/>,
|
||||
);
|
||||
|
||||
return <>
|
||||
{
|
||||
Array.from(rightPanelPhaseButtons.keys()).map((phase) =>
|
||||
(this.props.excludedRightPanelPhaseButtons?.includes(phase)
|
||||
return (
|
||||
<>
|
||||
{Array.from(rightPanelPhaseButtons.keys()).map((phase) =>
|
||||
this.props.excludedRightPanelPhaseButtons?.includes(phase)
|
||||
? null
|
||||
: rightPanelPhaseButtons.get(phase)))
|
||||
}
|
||||
</>;
|
||||
: rightPanelPhaseButtons.get(phase),
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue