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

Commit cdffbdb

Browse files
authored
Add error handling for room publish toggle (#12941)
* feat: added error handling for room publish toggle * chore: fixed the messages and removed `console.log` * chore: added minor comment that was removed * fix: addressed review comments * fix: fixed linting
1 parent 1e3320d commit cdffbdb

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/components/views/room_settings/RoomPublishSetting.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import LabelledToggleSwitch from "../elements/LabelledToggleSwitch";
2121
import { _t } from "../../../languageHandler";
2222
import { MatrixClientPeg } from "../../../MatrixClientPeg";
2323
import DirectoryCustomisations from "../../../customisations/Directory";
24+
import Modal from "../../../Modal";
25+
import ErrorDialog from "../dialogs/ErrorDialog";
2426

2527
interface IProps {
2628
roomId: string;
@@ -41,6 +43,13 @@ export default class RoomPublishSetting extends React.PureComponent<IProps, ISta
4143
};
4244
}
4345

46+
private showError(): void {
47+
Modal.createDialog(ErrorDialog, {
48+
title: _t("room_settings|general|error_publishing"),
49+
description: _t("room_settings|general|error_publishing_detail"),
50+
});
51+
}
52+
4453
private onRoomPublishChange = (): void => {
4554
const valueBefore = this.state.isRoomPublished;
4655
const newValue = !valueBefore;
@@ -50,6 +59,7 @@ export default class RoomPublishSetting extends React.PureComponent<IProps, ISta
5059
client
5160
.setRoomDirectoryVisibility(this.props.roomId, newValue ? Visibility.Public : Visibility.Private)
5261
.catch(() => {
62+
this.showError();
5363
// Roll back the local echo on the change
5464
this.setState({ isRoomPublished: valueBefore });
5565
});

src/i18n/strings/en_EN.json

+2
Original file line numberDiff line numberDiff line change
@@ -2214,6 +2214,8 @@
22142214
"error_deleting_alias_description": "There was an error removing that address. It may no longer exist or a temporary error occurred.",
22152215
"error_deleting_alias_description_forbidden": "You don't have permission to delete the address.",
22162216
"error_deleting_alias_title": "Error removing address",
2217+
"error_publishing": "Unable to publish room",
2218+
"error_publishing_detail": "There was an error publishing this room",
22172219
"error_save_space_settings": "Failed to save space settings.",
22182220
"error_updating_alias_description": "There was an error updating the room's alternative addresses. It may not be allowed by the server or a temporary failure occurred.",
22192221
"error_updating_canonical_alias_description": "There was an error updating the room's main address. It may not be allowed by the server or a temporary failure occurred.",

0 commit comments

Comments
 (0)