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

Commit 773b03e

Browse files
Pankaj-SinghRfloriandurosRiotRobotgithub-merge-queuet3chguy
authored
Added meaning full error message based on platform (#12074)
* fix: fixed 'Database unexpectedly closed' is a bad error message (#25948) * Added deviceType condition check for web and desktop * Added Error description for web and desktop * Changed 'error_database_closed_title' Title to '%(brand)s stopped working' Signed-off-by: Pankaj Singh <pankajsingh132000@gmail.com> * refactor(platform): replace UA parsing with Platform for platform detection Signed-off-by: Pankaj Singh <pankajsingh132000@gmail.com> * refactor(platform-test): added getHumanReadableName function in testcase Signed-off-by: Pankaj Singh <pankajsingh132000@gmail.com> * refactor(platform): added %brand argument for description Signed-off-by: Pankaj Singh <pankajsingh132000@gmail.com> * refactor by linter Signed-off-by: Pankaj Singh <pankajsingh132000@gmail.com> * refactor(linter): used prettier for linter * Enable `A thread with a redacted unread is still read after restart` (#12083) * [create-pull-request] automated change (#12085) Co-authored-by: github-merge-queue <github-merge-queue@users.noreply.github.com> * Allow element-web hash to be specified when calling playwright tests workflow (#12087) * add link to issue for disabled test * [create-pull-request] automated change (#12093) Co-authored-by: github-merge-queue <github-merge-queue@users.noreply.github.com> * Add tests about room list order (#12088) --------- Signed-off-by: Pankaj Singh <pankajsingh132000@gmail.com> Co-authored-by: Florian Duros <florianduros@element.io> Co-authored-by: ElementRobot <releases@riot.im> Co-authored-by: github-merge-queue <github-merge-queue@users.noreply.github.com> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Richard van der Hoff <richard@matrix.org>
1 parent 176237e commit 773b03e

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/MatrixClientPeg.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import MatrixClientBackedController from "./settings/controllers/MatrixClientBac
5151
import ErrorDialog from "./components/views/dialogs/ErrorDialog";
5252
import PlatformPeg from "./PlatformPeg";
5353
import { formatList } from "./utils/FormattingUtils";
54+
import SdkConfig from "./SdkConfig";
5455

5556
export interface IMatrixClientCreds {
5657
homeserverUrl: string;
@@ -212,12 +213,21 @@ class MatrixClientPegClass implements IMatrixClientPeg {
212213
// If the user is not a guest then prompt them to reload rather than doing it for them
213214
// For guests this is likely to happen during e-mail verification as part of registration
214215

215-
const { finished } = Modal.createDialog(ErrorDialog, {
216-
title: _t("error_database_closed_title"),
217-
description: _t("error_database_closed_description"),
216+
const brand = SdkConfig.get().brand;
217+
const platform = PlatformPeg.get()?.getHumanReadableName();
218+
219+
// Determine the description based on the platform
220+
const description =
221+
platform === "Web Platform"
222+
? _t("error_database_closed_description|for_web", { brand })
223+
: _t("error_database_closed_description|for_desktop");
224+
225+
const [reload] = await Modal.createDialog(ErrorDialog, {
226+
title: _t("error_database_closed_title", { brand }),
227+
description,
218228
button: _t("action|reload"),
219-
});
220-
const [reload] = await finished;
229+
}).finished;
230+
221231
if (!reload) return;
222232
}
223233

src/i18n/strings/en_EN.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,11 @@
10631063
"error_app_open_in_another_tab": "Switch to the other tab to connect to %(brand)s. This tab can now be closed.",
10641064
"error_app_open_in_another_tab_title": "%(brand)s is connected in another tab",
10651065
"error_app_opened_in_another_window": "%(brand)s is open in another window. Click \"%(label)s\" to use %(brand)s here and disconnect the other window.",
1066-
"error_database_closed_description": "This may be caused by having the app open in multiple tabs or due to clearing browser data.",
1067-
"error_database_closed_title": "Database unexpectedly closed",
1066+
"error_database_closed_description": {
1067+
"for_desktop": "Your disk may be full. Please clear up some space and reload.",
1068+
"for_web": "If you cleared browsing data then this message is expected. %(brand)s may also be open in another tab, or your disk is full. Please clear up some space and reload"
1069+
},
1070+
"error_database_closed_title": "%(brand)s stopped working",
10681071
"error_dialog": {
10691072
"copy_room_link_failed": {
10701073
"description": "Unable to copy a link to the room to the clipboard.",

test/MatrixClientPeg-test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ describe("MatrixClientPeg", () => {
155155
it("should show error modal when store database closes", async () => {
156156
testPeg.safeGet().isGuest = () => false;
157157
const emitter = new EventEmitter();
158+
const platform: any = { getHumanReadableName: jest.fn() };
159+
PlatformPeg.set(platform);
158160
testPeg.safeGet().store.on = emitter.on.bind(emitter);
159161
const spy = jest.spyOn(Modal, "createDialog");
160162
await testPeg.assign();

0 commit comments

Comments
 (0)