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

Commit

Permalink
Add error handling for room publish toggle (#12941)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sahil9001 committed Sep 5, 2024
1 parent 1e3320d commit cdffbdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions 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"),
});
}

private onRoomPublishChange = (): void => {
const valueBefore = this.state.isRoomPublished;
const newValue = !valueBefore;
Expand All @@ -50,6 +59,7 @@ export default class RoomPublishSetting extends React.PureComponent<IProps, ISta
client
.setRoomDirectoryVisibility(this.props.roomId, newValue ? Visibility.Public : Visibility.Private)
.catch(() => {
this.showError();
// Roll back the local echo on the change
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 @@ -2214,6 +2214,8 @@
"error_deleting_alias_description": "There was an error removing that address. It may no longer exist or a temporary error occurred.",
"error_deleting_alias_description_forbidden": "You don't have permission to delete the address.",
"error_deleting_alias_title": "Error removing address",
"error_publishing": "Unable to publish room",
"error_publishing_detail": "There was an error publishing this room",
"error_save_space_settings": "Failed to save space settings.",
"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.",
"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.",
Expand Down

0 comments on commit cdffbdb

Please sign in to comment.