From 818c5557993accb676c2272f1648fe47c73fc415 Mon Sep 17 00:00:00 2001 From: Sahil Silare Date: Sun, 1 Sep 2024 16:10:55 +0530 Subject: [PATCH 1/5] feat: added error handling for room publish toggle --- .../views/room_settings/RoomPublishSetting.tsx | 13 ++++++++++++- src/i18n/strings/en_EN.json | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/views/room_settings/RoomPublishSetting.tsx b/src/components/views/room_settings/RoomPublishSetting.tsx index 5fddb66a154..4c2e45d53a4 100644 --- a/src/components/views/room_settings/RoomPublishSetting.tsx +++ b/src/components/views/room_settings/RoomPublishSetting.tsx @@ -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; @@ -41,6 +43,13 @@ export default class RoomPublishSetting extends React.PureComponent { const valueBefore = this.state.isRoomPublished; const newValue = !valueBefore; @@ -49,8 +58,10 @@ export default class RoomPublishSetting extends React.PureComponent { + .catch((err) => { // Roll back the local echo on the change + console.log("here") + this.showError(); this.setState({ isRoomPublished: valueBefore }); }); }; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 352ab437629..6bdf0c091c8 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -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", "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.", From 32a62e2f2197483133a746970db03bd59dcb8269 Mon Sep 17 00:00:00 2001 From: Sahil Silare Date: Mon, 2 Sep 2024 19:01:37 +0530 Subject: [PATCH 2/5] chore: fixed the messages and removed `console.log` --- src/components/views/room_settings/RoomPublishSetting.tsx | 4 +--- src/i18n/strings/en_EN.json | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/views/room_settings/RoomPublishSetting.tsx b/src/components/views/room_settings/RoomPublishSetting.tsx index 4c2e45d53a4..d0a5f8ae080 100644 --- a/src/components/views/room_settings/RoomPublishSetting.tsx +++ b/src/components/views/room_settings/RoomPublishSetting.tsx @@ -58,9 +58,7 @@ export default class RoomPublishSetting extends React.PureComponent { - // Roll back the local echo on the change - console.log("here") + .catch(() => { this.showError(); this.setState({ isRoomPublished: valueBefore }); }); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 6bdf0c091c8..512e337d9c2 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2221,8 +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", + "error_publishing": "Unable to publish room", + "error_publishing_detail": "There was an error publishing this room", "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.", From 017062943686c5ee79dbb705e99b130f0949d564 Mon Sep 17 00:00:00 2001 From: Sahil Silare Date: Mon, 2 Sep 2024 21:48:59 +0530 Subject: [PATCH 3/5] chore: added minor comment that was removed --- src/components/views/room_settings/RoomPublishSetting.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/views/room_settings/RoomPublishSetting.tsx b/src/components/views/room_settings/RoomPublishSetting.tsx index d0a5f8ae080..5262216a19b 100644 --- a/src/components/views/room_settings/RoomPublishSetting.tsx +++ b/src/components/views/room_settings/RoomPublishSetting.tsx @@ -59,6 +59,7 @@ export default class RoomPublishSetting extends React.PureComponent { + // Roll back the local echo on the change this.showError(); this.setState({ isRoomPublished: valueBefore }); }); From aa968260a7ac9fb49ed9e16053ef4adb976edaf0 Mon Sep 17 00:00:00 2001 From: Sahil Silare Date: Tue, 3 Sep 2024 18:26:18 +0530 Subject: [PATCH 4/5] fix: addressed review comments --- src/components/views/room_settings/RoomPublishSetting.tsx | 2 +- src/i18n/strings/en_EN.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/room_settings/RoomPublishSetting.tsx b/src/components/views/room_settings/RoomPublishSetting.tsx index 5262216a19b..86c6fd6ae36 100644 --- a/src/components/views/room_settings/RoomPublishSetting.tsx +++ b/src/components/views/room_settings/RoomPublishSetting.tsx @@ -59,8 +59,8 @@ export default class RoomPublishSetting extends React.PureComponent { - // Roll back the local echo on the change this.showError(); + // Roll back the local echo on the change this.setState({ isRoomPublished: valueBefore }); }); }; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 512e337d9c2..d2dffe61bf7 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -2206,6 +2206,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.", @@ -2221,8 +2223,6 @@ "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": "Unable to publish room", - "error_publishing_detail": "There was an error publishing this room", "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.", From 3e76c26249f7d2245d8348a10355029860941fe9 Mon Sep 17 00:00:00 2001 From: Sahil Silare Date: Thu, 5 Sep 2024 08:32:45 +0530 Subject: [PATCH 5/5] fix: fixed linting --- src/components/views/room_settings/RoomPublishSetting.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/room_settings/RoomPublishSetting.tsx b/src/components/views/room_settings/RoomPublishSetting.tsx index 86c6fd6ae36..f97776bf94b 100644 --- a/src/components/views/room_settings/RoomPublishSetting.tsx +++ b/src/components/views/room_settings/RoomPublishSetting.tsx @@ -49,7 +49,7 @@ export default class RoomPublishSetting extends React.PureComponent { const valueBefore = this.state.isRoomPublished; const newValue = !valueBefore;