Skip to content

Commit 931edd7

Browse files
authored
Merge branch 'develop' into dbkr/stateafter
2 parents 044eaf7 + 88c72a1 commit 931edd7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+543
-631
lines changed

.github/workflows/static_analysis.yaml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,6 @@ jobs:
3434
- name: Typecheck
3535
run: "yarn run lint:types"
3636

37-
- name: Switch js-sdk to release mode
38-
working-directory: node_modules/matrix-js-sdk
39-
run: |
40-
scripts/switch_package_to_release.cjs
41-
yarn install
42-
yarn run build:compile
43-
yarn run build:types
44-
45-
- name: Typecheck (release mode)
46-
run: "yarn run lint:types"
47-
48-
# Temporary while we directly import matrix-js-sdk/src/* which means we need
49-
# certain @types/* packages to make sense of matrix-js-sdk types.
50-
#- name: Typecheck (release mode; no yarn link)
51-
# if: github.event_name != 'pull_request' && github.ref_name != 'master'
52-
# run: |
53-
# yarn unlink matrix-js-sdk
54-
# yarn add github:matrix-org/matrix-js-sdk#develop
55-
# yarn install --force
56-
# yarn run lint:types
57-
5837
i18n_lint:
5938
name: "i18n Check"
6039
uses: matrix-org/matrix-web-i18n/.github/workflows/i18n_check.yml@main

components.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"src/components/views/auth/AuthFooter.tsx": "src/components/views/auth/VectorAuthFooter.tsx",
3-
"src/components/views/auth/AuthHeaderLogo.tsx": "src/components/views/auth/VectorAuthHeaderLogo.tsx",
4-
"src/components/views/auth/AuthPage.tsx": "src/components/views/auth/VectorAuthPage.tsx"
5-
}
1+
{}

playwright/plugins/homeserver/synapse/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { randB64Bytes } from "../../utils/rand";
2020
// Docker tag to use for synapse docker image.
2121
// We target a specific digest as every now and then a Synapse update will break our CI.
2222
// This digest is updated by the playwright-image-updates.yaml workflow periodically.
23-
const DOCKER_TAG = "develop@sha256:df06607d21965639cb7dd72724fd610731c13bed95d3334746f53668a36c6cda";
23+
const DOCKER_TAG = "develop@sha256:6c33604ee62f009f3b34454a3c3e85f7e3ff5de63e45011fcd79e0ddc54a4e51";
2424

2525
async function cfgDirFromTemplate(opts: StartHomeserverOpts): Promise<Omit<HomeserverConfig, "dockerUrl">> {
2626
const templateDir = path.join(__dirname, "templates", opts.template);

src/BasePlatform.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import { ViewRoomPayload } from "./dispatcher/payloads/ViewRoomPayload";
3131
import { IConfigOptions } from "./IConfigOptions";
3232
import SdkConfig from "./SdkConfig";
3333
import { buildAndEncodePickleKey, encryptPickleKey } from "./utils/tokens/pickling";
34+
import Favicon from "./favicon.ts";
35+
import { getVectorConfig } from "./vector/getconfig.ts";
3436

3537
export const SSO_HOMESERVER_URL_KEY = "mx_sso_hs_url";
3638
export const SSO_ID_SERVER_URL_KEY = "mx_sso_is_url";
@@ -66,14 +68,20 @@ const UPDATE_DEFER_KEY = "mx_defer_update";
6668
export default abstract class BasePlatform {
6769
protected notificationCount = 0;
6870
protected errorDidOccur = false;
71+
protected _favicon?: Favicon;
6972

7073
protected constructor() {
7174
dis.register(this.onAction);
7275
this.startUpdateCheck = this.startUpdateCheck.bind(this);
7376
}
7477

75-
public abstract getConfig(): Promise<IConfigOptions | undefined>;
78+
public async getConfig(): Promise<IConfigOptions | undefined> {
79+
return getVectorConfig();
80+
}
7681

82+
/**
83+
* Get a sensible default display name for the device Element is running on
84+
*/
7785
public abstract getDefaultDeviceDisplayName(): string;
7886

7987
protected onAction = (payload: ActionPayload): void => {
@@ -89,11 +97,15 @@ export default abstract class BasePlatform {
8997
public abstract getHumanReadableName(): string;
9098

9199
public setNotificationCount(count: number): void {
100+
if (this.notificationCount === count) return;
92101
this.notificationCount = count;
102+
this.updateFavicon();
93103
}
94104

95105
public setErrorStatus(errorDidOccur: boolean): void {
106+
if (this.errorDidOccur === errorDidOccur) return;
96107
this.errorDidOccur = errorDidOccur;
108+
this.updateFavicon();
97109
}
98110

99111
/**
@@ -456,4 +468,34 @@ export default abstract class BasePlatform {
456468
url.hash = "";
457469
return url;
458470
}
471+
472+
/**
473+
* Delay creating the `Favicon` instance until first use (on the first notification) as
474+
* it uses canvas, which can trigger a permission prompt in Firefox's resist fingerprinting mode.
475+
* See https://github.com/element-hq/element-web/issues/9605.
476+
*/
477+
public get favicon(): Favicon {
478+
if (this._favicon) {
479+
return this._favicon;
480+
}
481+
this._favicon = new Favicon();
482+
return this._favicon;
483+
}
484+
485+
private updateFavicon(): void {
486+
let bgColor = "#d00";
487+
let notif: string | number = this.notificationCount;
488+
489+
if (this.errorDidOccur) {
490+
notif = notif || "×";
491+
bgColor = "#f00";
492+
}
493+
494+
this.favicon.badge(notif, { bgColor });
495+
}
496+
497+
/**
498+
* Begin update polling, if applicable
499+
*/
500+
public startUpdater(): void {}
459501
}

src/components/views/auth/AuthFooter.tsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,36 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
77
Please see LICENSE files in the repository root for full details.
88
*/
99

10-
import React from "react";
10+
import React, { ReactElement } from "react";
1111

12+
import SdkConfig from "../../../SdkConfig";
1213
import { _t } from "../../../languageHandler";
1314

14-
export default class AuthFooter extends React.Component {
15-
public render(): React.ReactNode {
16-
return (
17-
<footer className="mx_AuthFooter" role="contentinfo">
18-
<a href="https://matrix.org" target="_blank" rel="noreferrer noopener">
19-
{_t("auth|footer_powered_by_matrix")}
20-
</a>
21-
</footer>
15+
const AuthFooter = (): ReactElement => {
16+
const brandingConfig = SdkConfig.getObject("branding");
17+
const links = brandingConfig?.get("auth_footer_links") ?? [
18+
{ text: "Blog", url: "https://element.io/blog" },
19+
{ text: "Twitter", url: "https://twitter.com/element_hq" },
20+
{ text: "GitHub", url: "https://github.com/element-hq/element-web" },
21+
];
22+
23+
const authFooterLinks: JSX.Element[] = [];
24+
for (const linkEntry of links) {
25+
authFooterLinks.push(
26+
<a href={linkEntry.url} key={linkEntry.text} target="_blank" rel="noreferrer noopener">
27+
{linkEntry.text}
28+
</a>,
2229
);
2330
}
24-
}
31+
32+
return (
33+
<footer className="mx_AuthFooter" role="contentinfo">
34+
{authFooterLinks}
35+
<a href="https://matrix.org" target="_blank" rel="noreferrer noopener">
36+
{_t("powered_by_matrix")}
37+
</a>
38+
</footer>
39+
);
40+
};
41+
42+
export default AuthFooter;
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
/*
22
Copyright 2019-2024 New Vector Ltd.
3+
Copyright 2015, 2016 OpenMarket Ltd
34
45
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
56
Please see LICENSE files in the repository root for full details.
67
*/
78

89
import React from "react";
910

11+
import SdkConfig from "../../../SdkConfig";
12+
1013
export default class AuthHeaderLogo extends React.PureComponent {
11-
public render(): React.ReactNode {
12-
return <aside className="mx_AuthHeaderLogo">Matrix</aside>;
14+
public render(): React.ReactElement {
15+
const brandingConfig = SdkConfig.getObject("branding");
16+
const logoUrl = brandingConfig?.get("auth_header_logo_url") ?? "themes/element/img/logos/element-logo.svg";
17+
18+
return (
19+
<aside className="mx_AuthHeaderLogo">
20+
<img src={logoUrl} alt="Element" />
21+
</aside>
22+
);
1323
}
1424
}

src/components/views/auth/AuthPage.tsx

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,69 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
77
Please see LICENSE files in the repository root for full details.
88
*/
99

10-
import React, { ReactNode } from "react";
10+
import React from "react";
1111

12+
import SdkConfig from "../../../SdkConfig";
1213
import AuthFooter from "./AuthFooter";
1314

14-
export default class AuthPage extends React.PureComponent<{ children: ReactNode }> {
15-
public render(): React.ReactNode {
15+
export default class AuthPage extends React.PureComponent<React.PropsWithChildren> {
16+
private static welcomeBackgroundUrl?: string;
17+
18+
// cache the url as a static to prevent it changing without refreshing
19+
private static getWelcomeBackgroundUrl(): string {
20+
if (AuthPage.welcomeBackgroundUrl) return AuthPage.welcomeBackgroundUrl;
21+
22+
const brandingConfig = SdkConfig.getObject("branding");
23+
AuthPage.welcomeBackgroundUrl = "themes/element/img/backgrounds/lake.jpg";
24+
25+
const configuredUrl = brandingConfig?.get("welcome_background_url");
26+
if (configuredUrl) {
27+
if (Array.isArray(configuredUrl)) {
28+
const index = Math.floor(Math.random() * configuredUrl.length);
29+
AuthPage.welcomeBackgroundUrl = configuredUrl[index];
30+
} else {
31+
AuthPage.welcomeBackgroundUrl = configuredUrl;
32+
}
33+
}
34+
35+
return AuthPage.welcomeBackgroundUrl;
36+
}
37+
38+
public render(): React.ReactElement {
39+
const pageStyle = {
40+
background: `center/cover fixed url(${AuthPage.getWelcomeBackgroundUrl()})`,
41+
};
42+
43+
const modalStyle: React.CSSProperties = {
44+
position: "relative",
45+
background: "initial",
46+
};
47+
48+
const blurStyle: React.CSSProperties = {
49+
position: "absolute",
50+
top: 0,
51+
right: 0,
52+
bottom: 0,
53+
left: 0,
54+
filter: "blur(40px)",
55+
background: pageStyle.background,
56+
};
57+
58+
const modalContentStyle: React.CSSProperties = {
59+
display: "flex",
60+
zIndex: 1,
61+
background: "rgba(255, 255, 255, 0.59)",
62+
borderRadius: "8px",
63+
};
64+
1665
return (
17-
<div className="mx_AuthPage">
18-
<div className="mx_AuthPage_modal">{this.props.children}</div>
66+
<div className="mx_AuthPage" style={pageStyle}>
67+
<div className="mx_AuthPage_modal" style={modalStyle}>
68+
<div className="mx_AuthPage_modalBlur" style={blurStyle} />
69+
<div className="mx_AuthPage_modalContent" style={modalContentStyle}>
70+
{this.props.children}
71+
</div>
72+
</div>
1973
<AuthFooter />
2074
</div>
2175
);

src/components/views/auth/VectorAuthFooter.tsx

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/components/views/auth/VectorAuthHeaderLogo.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)