Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add error handling for room publish toggle #12941

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/components/views/room_settings/RoomPublishSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import LabelledToggleSwitch from "../elements/LabelledToggleSwitch";
import { _t } from "../../../languageHandler";
import { MatrixClientPeg } from "../../../MatrixClientPeg";
import DirectoryCustomisations from "../../../customisations/Directory";
import Modal from "../../../Modal";
import ErrorDialog from "../dialogs/ErrorDialog";

interface IProps {
roomId: string;
Expand All @@ -41,6 +43,13 @@ export default class RoomPublishSetting extends React.PureComponent<IProps, ISta
};
}

private showError(): void {
Modal.createDialog(ErrorDialog, {
title: _t("room_settings|general|error_publishing"),
description: _t("room_settings|general|error_publishing_detail"),
});
}

sahil9001 marked this conversation as resolved.
Show resolved Hide resolved
private onRoomPublishChange = (): void => {
const valueBefore = this.state.isRoomPublished;
const newValue = !valueBefore;
Expand All @@ -49,8 +58,10 @@ export default class RoomPublishSetting extends React.PureComponent<IProps, ISta

client
.setRoomDirectoryVisibility(this.props.roomId, newValue ? Visibility.Public : Visibility.Private)
.catch(() => {
.catch((err) => {
dbkr marked this conversation as resolved.
Show resolved Hide resolved
// Roll back the local echo on the change
dbkr marked this conversation as resolved.
Show resolved Hide resolved
console.log("here")
dbkr marked this conversation as resolved.
Show resolved Hide resolved
this.showError();
this.setState({ isRoomPublished: valueBefore });
});
};
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2221,6 +2221,8 @@
"no_aliases_space": "This space has no local addresses",
"other_section": "Other",
"publish_toggle": "Publish this room to the public in %(domain)s's room directory?",
"error_publishing": "There was an error publishing this room",
"error_publishing_detail": "Not allowed to publish room",
dbkr marked this conversation as resolved.
Show resolved Hide resolved
"published_aliases_description": "To publish an address, it needs to be set as a local address first.",
"published_aliases_explainer_room": "Published addresses can be used by anyone on any server to join your room.",
"published_aliases_explainer_space": "Published addresses can be used by anyone on any server to join your space.",
Expand Down
Loading