#21451 Fix WebGL disabled error message (#10589)

* #21451 Fix WebGl disabled error message

* #21451 Fix WebGl disabled error message

Signed-off-by: Rashmit Pankhania <rashmitpankhania@gmail.com>
Signed-off-by: Rashmit Pankhania <raspankh@publicisgroupe.net>

* Fix message

Signed-off-by: Rashmit Pankhania <raspankh@publicisgroupe.net>

* Fix ordering of cases in LocationShareErrors.ts

Signed-off-by: Rashmit Pankhania <raspankh@publicisgroupe.net>

* Fix linting LocationPicker.tsx

Signed-off-by: Rashmit Pankhania <raspankh@publicisgroupe.net>

* Fix eslint

Signed-off-by: Rashmit Pankhania <raspankh@publicisgroupe.net>

* Fix file encoding for i18n CI issue

Signed-off-by: Rashmit Pankhania <raspankh@publicisgroupe.net>

* Fix ts strict CI issue

Signed-off-by: Rashmit Pankhania <raspankh@publicisgroupe.net>

---------

Signed-off-by: Rashmit Pankhania <rashmitpankhania@gmail.com>
Signed-off-by: Rashmit Pankhania <raspankh@publicisgroupe.net>
Co-authored-by: Rashmit Pankhania <raspankh@publicisgroupe.net>
Co-authored-by: Kerry <kerrya@element.io>
This commit is contained in:
Rashmit Pankhania 2023-04-17 09:55:04 +05:30 committed by GitHub
parent 41c0b0881a
commit 7751f9c622
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 4 deletions

View file

@ -119,10 +119,13 @@ class LocationPicker extends React.Component<ILocationPickerProps, IState> {
} }
} catch (e) { } catch (e) {
logger.error("Failed to render map", e); logger.error("Failed to render map", e);
const errorType = const errorMessage = (e as Error)?.message;
(e as Error)?.message === LocationShareError.MapStyleUrlNotConfigured let errorType;
? LocationShareError.MapStyleUrlNotConfigured if (errorMessage === LocationShareError.MapStyleUrlNotConfigured)
: LocationShareError.Default; errorType = LocationShareError.MapStyleUrlNotConfigured;
else if (errorMessage.includes("Failed to initialize WebGL"))
errorType = LocationShareError.WebGLNotEnabled;
else errorType = LocationShareError.Default;
this.setState({ error: errorType }); this.setState({ error: errorType });
} }
} }

View file

@ -786,6 +786,7 @@
"No media permissions": "No media permissions", "No media permissions": "No media permissions",
"You may need to manually permit %(brand)s to access your microphone/webcam": "You may need to manually permit %(brand)s to access your microphone/webcam", "You may need to manually permit %(brand)s to access your microphone/webcam": "You may need to manually permit %(brand)s to access your microphone/webcam",
"This homeserver is not configured to display maps.": "This homeserver is not configured to display maps.", "This homeserver is not configured to display maps.": "This homeserver is not configured to display maps.",
"WebGL is required to display maps, please enable it in your browser settings.": "WebGL is required to display maps, please enable it in your browser settings.",
"This homeserver is not configured correctly to display maps, or the configured map server may be unreachable.": "This homeserver is not configured correctly to display maps, or the configured map server may be unreachable.", "This homeserver is not configured correctly to display maps, or the configured map server may be unreachable.": "This homeserver is not configured correctly to display maps, or the configured map server may be unreachable.",
"Toggle attribution": "Toggle attribution", "Toggle attribution": "Toggle attribution",
"Map feedback": "Map feedback", "Map feedback": "Map feedback",

View file

@ -19,6 +19,7 @@ import { _t } from "../../languageHandler";
export enum LocationShareError { export enum LocationShareError {
MapStyleUrlNotConfigured = "MapStyleUrlNotConfigured", MapStyleUrlNotConfigured = "MapStyleUrlNotConfigured",
MapStyleUrlNotReachable = "MapStyleUrlNotReachable", MapStyleUrlNotReachable = "MapStyleUrlNotReachable",
WebGLNotEnabled = "WebGLNotEnabled",
Default = "Default", Default = "Default",
} }
@ -26,6 +27,8 @@ export const getLocationShareErrorMessage = (errorType?: LocationShareError): st
switch (errorType) { switch (errorType) {
case LocationShareError.MapStyleUrlNotConfigured: case LocationShareError.MapStyleUrlNotConfigured:
return _t("This homeserver is not configured to display maps."); return _t("This homeserver is not configured to display maps.");
case LocationShareError.WebGLNotEnabled:
return _t("WebGL is required to display maps, please enable it in your browser settings.");
case LocationShareError.MapStyleUrlNotReachable: case LocationShareError.MapStyleUrlNotReachable:
default: default:
return _t( return _t(

View file

@ -57,6 +57,8 @@ export const createMap = (interactive: boolean, bodyId: string, onError?: (error
return map; return map;
} catch (e) { } catch (e) {
logger.error("Failed to render map", e); logger.error("Failed to render map", e);
const errorMessage = (e as Error)?.message;
if (errorMessage.includes("Failed to initialize WebGL")) throw new Error(LocationShareError.WebGLNotEnabled);
throw e; throw e;
} }
}; };

View file

@ -118,6 +118,20 @@ describe("LocationPicker", () => {
expect(getByText("This homeserver is not configured to display maps.")).toBeInTheDocument(); expect(getByText("This homeserver is not configured to display maps.")).toBeInTheDocument();
}); });
it("displays error when WebGl is not enabled", () => {
// suppress expected error log
jest.spyOn(logger, "error").mockImplementation(() => {});
mocked(findMapStyleUrl).mockImplementation(() => {
throw new Error("Failed to initialize WebGL");
});
const { getByText } = getComponent();
expect(
getByText("WebGL is required to display maps, please enable it in your browser settings."),
).toBeInTheDocument();
});
it("displays error when map setup throws", () => { it("displays error when map setup throws", () => {
// suppress expected error log // suppress expected error log
jest.spyOn(logger, "error").mockImplementation(() => {}); jest.spyOn(logger, "error").mockImplementation(() => {});