Merge branch 'develop' into germain-gg/notifications-labs

This commit is contained in:
RMidhunSuresh 2023-09-15 16:28:59 +05:30
commit 2f69013f6d
No known key found for this signature in database
73 changed files with 3445 additions and 3395 deletions

View file

@ -129,6 +129,7 @@ import { WaitingForThirdPartyRoomView } from "./WaitingForThirdPartyRoomView";
import { isNotUndefined } from "../../Typeguards";
import { CancelAskToJoinPayload } from "../../dispatcher/payloads/CancelAskToJoinPayload";
import { SubmitAskToJoinPayload } from "../../dispatcher/payloads/SubmitAskToJoinPayload";
import RightPanelStore from "../../stores/right-panel/RightPanelStore";
const DEBUG = false;
const PREVENT_MULTIPLE_JITSI_WITHIN = 30_000;
@ -1248,6 +1249,33 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
this.messagePanel?.jumpToLiveTimeline();
}
break;
case Action.ViewUser:
if (payload.member) {
if (payload.push) {
RightPanelStore.instance.pushCard({
phase: RightPanelPhases.RoomMemberInfo,
state: { member: payload.member },
});
} else {
RightPanelStore.instance.setCards([
{ phase: RightPanelPhases.RoomSummary },
{ phase: RightPanelPhases.RoomMemberList },
{ phase: RightPanelPhases.RoomMemberInfo, state: { member: payload.member } },
]);
}
} else {
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomMemberList);
}
break;
case "view_3pid_invite":
if (payload.event) {
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.Room3pidMemberInfo, {
memberInfoEvent: payload.event,
});
} else {
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomMemberList);
}
break;
}
};
@ -1784,12 +1812,13 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
};
private onSearchClick = (): void => {
this.setState({
timelineRenderingType:
this.state.timelineRenderingType === TimelineRenderingType.Search
? TimelineRenderingType.Room
: TimelineRenderingType.Search,
});
if (this.state.timelineRenderingType === TimelineRenderingType.Search) {
this.onCancelSearchClick();
} else {
this.setState({
timelineRenderingType: TimelineRenderingType.Search,
});
}
};
private onCancelSearchClick = (): Promise<void> => {

View file

@ -36,7 +36,6 @@ import { inviteMultipleToRoom, showRoomInviteDialog } from "../../RoomInvite";
import { UIComponent } from "../../settings/UIFeature";
import { UPDATE_EVENT } from "../../stores/AsyncStore";
import RightPanelStore from "../../stores/right-panel/RightPanelStore";
import { IRightPanelCard } from "../../stores/right-panel/RightPanelStoreIPanelState";
import { RightPanelPhases } from "../../stores/right-panel/RightPanelStorePhases";
import ResizeNotifier from "../../utils/ResizeNotifier";
import {
@ -669,33 +668,6 @@ export default class SpaceRoomView extends React.PureComponent<IProps, IState> {
this.setState({ phase: Phase.Landing });
return;
}
if (payload.action !== Action.ViewUser && payload.action !== "view_3pid_invite") return;
if (payload.action === Action.ViewUser && payload.member) {
const spaceMemberInfoCard: IRightPanelCard = {
phase: RightPanelPhases.SpaceMemberInfo,
state: { spaceId: this.props.space.roomId, member: payload.member },
};
if (payload.push) {
RightPanelStore.instance.pushCard(spaceMemberInfoCard);
} else {
RightPanelStore.instance.setCards([
{ phase: RightPanelPhases.SpaceMemberList, state: { spaceId: this.props.space.roomId } },
spaceMemberInfoCard,
]);
}
} else if (payload.action === "view_3pid_invite" && payload.event) {
RightPanelStore.instance.setCard({
phase: RightPanelPhases.Space3pidMemberInfo,
state: { spaceId: this.props.space.roomId, memberInfoEvent: payload.event },
});
} else {
RightPanelStore.instance.setCard({
phase: RightPanelPhases.SpaceMemberList,
state: { spaceId: this.props.space.roomId },
});
}
};
private goToFirstRoom = async (): Promise<void> => {

View file

@ -25,7 +25,7 @@ export default class AuthFooter extends React.Component {
return (
<footer className="mx_AuthFooter" role="contentinfo">
<a href="https://matrix.org" target="_blank" rel="noreferrer noopener">
{_t("powered by Matrix")}
{_t("auth|footer_powered_by_matrix")}
</a>
</footer>
);

View file

@ -19,16 +19,12 @@ import classNames from "classnames";
import SdkConfig from "../../../SdkConfig";
import AuthPage from "./AuthPage";
import { _td } from "../../../languageHandler";
import SettingsStore from "../../../settings/SettingsStore";
import { UIFeature } from "../../../settings/UIFeature";
import LanguageSelector from "./LanguageSelector";
import EmbeddedPage from "../../structures/EmbeddedPage";
import { MATRIX_LOGO_HTML } from "../../structures/static-page-vars";
// translatable strings for Welcome pages
_td("Sign in with SSO");
interface IProps {}
export default class Welcome extends React.PureComponent<IProps> {

View file

@ -257,7 +257,7 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
{
key: "required",
test: async ({ value }) => !!value,
invalid: () => _t("Please enter a name for the room"),
invalid: () => _t("create_room|name_validation_required"),
},
],
});
@ -285,54 +285,48 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
publicPrivateLabel = (
<p>
{_t(
"Everyone in <SpaceName/> will be able to find and join this room.",
"create_room|join_rule_restricted_label",
{},
{
SpaceName: () => <b>{this.props.parentSpace?.name ?? _t("common|unnamed_space")}</b>,
},
)}
&nbsp;
{_t("You can change this at any time from room settings.")}
{_t("create_room|join_rule_change_notice")}
</p>
);
} else if (this.state.joinRule === JoinRule.Public && this.props.parentSpace) {
publicPrivateLabel = (
<p>
{_t(
"Anyone will be able to find and join this room, not just members of <SpaceName/>.",
"create_room|join_rule_public_parent_space_label",
{},
{
SpaceName: () => <b>{this.props.parentSpace?.name ?? _t("common|unnamed_space")}</b>,
},
)}
&nbsp;
{_t("You can change this at any time from room settings.")}
{_t("create_room|join_rule_change_notice")}
</p>
);
} else if (this.state.joinRule === JoinRule.Public) {
publicPrivateLabel = (
<p>
{_t("Anyone will be able to find and join this room.")}
{_t("create_room|join_rule_public_label")}
&nbsp;
{_t("You can change this at any time from room settings.")}
{_t("create_room|join_rule_change_notice")}
</p>
);
} else if (this.state.joinRule === JoinRule.Invite) {
publicPrivateLabel = (
<p>
{_t("Only people invited will be able to find and join this room.")}
{_t("create_room|join_rule_invite_label")}
&nbsp;
{_t("You can change this at any time from room settings.")}
{_t("create_room|join_rule_change_notice")}
</p>
);
} else if (this.state.joinRule === JoinRule.Knock) {
publicPrivateLabel = (
<p>
{_t(
"Anyone can request to join, but admins or moderators need to grant access. You can change this later.",
)}
</p>
);
publicPrivateLabel = <p>{_t("create_room|join_rule_knock_label")}</p>;
}
let visibilitySection: JSX.Element | undefined;
@ -353,10 +347,10 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
if (privateShouldBeEncrypted(MatrixClientPeg.safeGet())) {
if (this.state.canChangeEncryption) {
microcopy = isVideoRoom
? _t("You can't disable this later. The room will be encrypted but the embedded call will not.")
: _t("You can't disable this later. Bridges & most bots won't work yet.");
? _t("create_room|encrypted_video_room_warning")
: _t("create_room|encrypted_warning");
} else {
microcopy = _t("Your server requires encryption to be enabled in private rooms.");
microcopy = _t("create_room|encryption_forced");
}
} else {
microcopy = _t(
@ -366,7 +360,7 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
e2eeSection = (
<React.Fragment>
<LabelledToggleSwitch
label={_t("Enable end-to-end encryption")}
label={_t("create_room|encryption_label")}
onChange={this.onEncryptedChange}
value={this.state.isEncrypted}
className="mx_CreateRoomDialog_e2eSwitch" // for end-to-end tests
@ -377,15 +371,11 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
);
}
let federateLabel = _t(
"You might enable this if the room will only be used for collaborating with internal teams on your homeserver. This cannot be changed later.",
);
let federateLabel = _t("create_room|unfederated_label_default_off");
if (SdkConfig.get().default_federate === false) {
// We only change the label if the default setting is different to avoid jarring text changes to the
// user. They will have read the implications of turning this off/on, so no need to rephrase for them.
federateLabel = _t(
"You might disable this if the room will be used for collaborating with external teams who have their own homeserver. This cannot be changed later.",
);
federateLabel = _t("create_room|unfederated_label_default_on");
}
let title: string;
@ -418,18 +408,20 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
className="mx_CreateRoomDialog_name"
/>
<Field
label={_t("Topic (optional)")}
label={_t("create_room|topic_label")}
onChange={this.onTopicChange}
value={this.state.topic}
className="mx_CreateRoomDialog_topic"
/>
<JoinRuleDropdown
label={_t("Room visibility")}
labelInvite={_t("Private room (invite only)")}
label={_t("create_room|room_visibility_label")}
labelInvite={_t("create_room|join_rule_invite")}
labelKnock={this.askToJoinEnabled ? _t("Ask to join") : undefined}
labelPublic={_t("Public room")}
labelRestricted={this.supportsRestricted ? _t("Visible to space members") : undefined}
labelRestricted={
this.supportsRestricted ? _t("create_room|join_rule_restricted") : undefined
}
value={this.state.joinRule}
onChange={this.onJoinRuleChange}
/>
@ -443,7 +435,7 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
{this.state.detailsOpen ? _t("Hide advanced") : _t("Show advanced")}
</summary>
<LabelledToggleSwitch
label={_t("Block anyone not part of %(serverName)s from ever joining this room.", {
label={_t("create_room|unfederated", {
serverName: MatrixClientPeg.getHomeserverName(),
})}
onChange={this.onNoFederateChange}

View file

@ -164,7 +164,7 @@ const CreateSubspaceDialog: React.FC<IProps> = ({ space, onAddExistingSpaceClick
label={_t("Space visibility")}
labelInvite={_t("Private space (invite only)")}
labelPublic={_t("Public space")}
labelRestricted={_t("Visible to space members")}
labelRestricted={_t("create_room|join_rule_restricted")}
width={478}
value={joinRule}
onChange={setJoinRule}

View file

@ -23,7 +23,6 @@ import React from "react";
import dis from "../../../dispatcher/dispatcher";
import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
import { RightPanelPhases } from "../../../stores/right-panel/RightPanelStorePhases";
import { IRightPanelCardState } from "../../../stores/right-panel/RightPanelStoreIPanelState";
import { UPDATE_EVENT } from "../../../stores/AsyncStore";
import { NotificationColor } from "../../../stores/notifications/NotificationColor";
import { ActionPayload } from "../../../dispatcher/payloads";
@ -66,7 +65,6 @@ export default abstract class HeaderButtons<P = {}> extends React.Component<IPro
public componentDidMount(): void {
RightPanelStore.instance.on(UPDATE_EVENT, this.onRightPanelStoreUpdate);
this.dispatcherRef = dis.register(this.onAction.bind(this)); // used by subclasses
}
public componentWillUnmount(): void {
@ -76,18 +74,6 @@ export default abstract class HeaderButtons<P = {}> extends React.Component<IPro
if (this.watcherRef) SettingsStore.unwatchSetting(this.watcherRef);
}
protected abstract onAction(payload: ActionPayload): void;
public setPhase(phase: RightPanelPhases, cardState?: Partial<IRightPanelCardState>): void {
const rps = RightPanelStore.instance;
if (rps.currentCard.phase == phase && !cardState && rps.isOpen) {
rps.togglePanel(null);
} else {
RightPanelStore.instance.setCard({ phase, state: cardState });
if (!rps.isOpen) rps.togglePanel(null);
}
}
public isPhase(phases: string | string[]): boolean {
if (!RightPanelStore.instance.isOpen) return false;
if (Array.isArray(phases)) {

View file

@ -26,7 +26,6 @@ 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";
@ -203,59 +202,34 @@ export default class LegacyRoomHeaderButtons extends HeaderButtons<IProps> {
});
};
protected onAction(payload: ActionPayload): void {
if (payload.action === Action.ViewUser) {
if (payload.member) {
if (payload.push) {
RightPanelStore.instance.pushCard({
phase: RightPanelPhases.RoomMemberInfo,
state: { member: payload.member },
});
} else {
RightPanelStore.instance.setCards([
{ phase: RightPanelPhases.RoomSummary },
{ phase: RightPanelPhases.RoomMemberList },
{ phase: RightPanelPhases.RoomMemberInfo, state: { member: payload.member } },
]);
}
} else {
this.setPhase(RightPanelPhases.RoomMemberList);
}
} else if (payload.action === "view_3pid_invite") {
if (payload.event) {
this.setPhase(RightPanelPhases.Room3pidMemberInfo, { memberInfoEvent: payload.event });
} else {
this.setPhase(RightPanelPhases.RoomMemberList);
}
}
}
protected onAction(payload: ActionPayload): void {}
private onRoomSummaryClicked = (): void => {
// use roomPanelPhase rather than this.state.phase as it remembers the latest one if we close
const currentPhase = RightPanelStore.instance.currentCard.phase;
if (currentPhase && ROOM_INFO_PHASES.includes(currentPhase)) {
if (this.state.phase === currentPhase) {
this.setPhase(currentPhase);
RightPanelStore.instance.showOrHidePanel(currentPhase);
} else {
this.setPhase(currentPhase, RightPanelStore.instance.currentCard.state);
RightPanelStore.instance.showOrHidePanel(currentPhase, RightPanelStore.instance.currentCard.state);
}
} else {
// This toggles for us, if needed
this.setPhase(RightPanelPhases.RoomSummary);
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomSummary);
}
};
private onNotificationsClicked = (): void => {
// This toggles for us, if needed
this.setPhase(RightPanelPhases.NotificationPanel);
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.NotificationPanel);
};
private onPinnedMessagesClicked = (): void => {
// This toggles for us, if needed
this.setPhase(RightPanelPhases.PinnedMessages);
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.PinnedMessages);
};
private onTimelineCardClicked = (): void => {
this.setPhase(RightPanelPhases.Timeline);
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.Timeline);
};
private onThreadsPanelClicked = (ev: ButtonEvent): void => {

View file

@ -30,15 +30,19 @@ const HistoryTile: React.FC = () => {
let subtitle: string | undefined;
if (historyState == "invited") {
subtitle = _t("You don't have permission to view messages from before you were invited.");
subtitle = _t("timeline|no_permission_messages_before_invite");
} else if (historyState == "joined") {
subtitle = _t("You don't have permission to view messages from before you joined.");
subtitle = _t("timeline|no_permission_messages_before_join");
} else if (encryptionState) {
subtitle = _t("Encrypted messages before this point are unavailable.");
subtitle = _t("timeline|encrypted_historical_messages_unavailable");
}
return (
<EventTileBubble className="mx_HistoryTile" title={_t("You can't see earlier messages")} subtitle={subtitle} />
<EventTileBubble
className="mx_HistoryTile"
title={_t("timeline|historical_messages_unavailable")}
subtitle={subtitle}
/>
);
};

View file

@ -28,7 +28,6 @@ import { EventType, JoinRule, type Room } from "matrix-js-sdk/src/matrix";
import { useRoomName } from "../../../hooks/useRoomName";
import { RightPanelPhases } from "../../../stores/right-panel/RightPanelStorePhases";
import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
import { useTopic } from "../../../hooks/room/useTopic";
import { useAccountData } from "../../../hooks/useAccountData";
import { useMatrixClientContext } from "../../../contexts/MatrixClientContext";
@ -49,6 +48,7 @@ import FacePile from "../elements/FacePile";
import { useRoomState } from "../../../hooks/useRoomState";
import RoomAvatar from "../avatars/RoomAvatar";
import { formatCount } from "../../../utils/FormattingUtils";
import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
/**
* A helper to transform a notification color to the what the Compound Icon Button
@ -64,16 +64,6 @@ function notificationColorToIndicator(color: NotificationColor): React.Component
}
}
/**
* A helper to show or hide the right panel
*/
function showOrHidePanel(phase: RightPanelPhases): void {
const rightPanel = RightPanelStore.instance;
rightPanel.isOpen && rightPanel.currentCard.phase === phase
? rightPanel.togglePanel(null)
: rightPanel.setCard({ phase });
}
export default function RoomHeader({ room }: { room: Room }): JSX.Element {
const client = useMatrixClientContext();
@ -119,7 +109,7 @@ export default function RoomHeader({ room }: { room: Room }): JSX.Element {
gap="var(--cpd-space-3x)"
className="mx_RoomHeader light-panel"
onClick={() => {
showOrHidePanel(RightPanelPhases.RoomSummary);
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomSummary);
}}
>
<RoomAvatar room={room} size="40px" />
@ -207,7 +197,7 @@ export default function RoomHeader({ room }: { room: Room }): JSX.Element {
indicator={notificationColorToIndicator(threadNotifications)}
onClick={(evt) => {
evt.stopPropagation();
showOrHidePanel(RightPanelPhases.ThreadPanel);
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.ThreadPanel);
}}
title={_t("common|threads")}
>
@ -220,7 +210,7 @@ export default function RoomHeader({ room }: { room: Room }): JSX.Element {
indicator={notificationColorToIndicator(globalNotificationState.color)}
onClick={(evt) => {
evt.stopPropagation();
showOrHidePanel(RightPanelPhases.NotificationPanel);
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.NotificationPanel);
}}
title={_t("Notifications")}
>
@ -236,7 +226,7 @@ export default function RoomHeader({ room }: { room: Room }): JSX.Element {
weight="medium"
aria-label={_t("%(count)s members", { count: memberCount })}
onClick={(e: React.MouseEvent) => {
showOrHidePanel(RightPanelPhases.RoomMemberList);
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomMemberList);
e.stopPropagation();
}}
>

View file

@ -90,10 +90,9 @@ export function attachMentions(
replyToEvent: MatrixEvent | undefined,
editedContent: IContent | null = null,
): void {
// If this feature is disabled, do nothing.
if (!SettingsStore.getValue("feature_intentional_mentions")) {
return;
}
// We always attach the mentions even if the home server doesn't yet support
// intentional mentions. This is safe because m.mentions is an additive change
// that should simply be ignored by incapable home servers.
// The mentions property *always* gets included to disable legacy push rules.
const mentions: IMentions = (content["m.mentions"] = {});