Skip to content

Commit ee03527

Browse files
committed
lint
1 parent 2ad3656 commit ee03527

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

docs/config.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,18 @@ Starting with `branding`, the following subproperties are available:
212212
3. `auth_footer_links`: A list of links to add to the footer during login, registration, etc. Each entry must have a `text` and
213213
`url` property.
214214

215-
216215
4. `title_template`: A template string that can be used to configure the title of the application when not viewing a room.
217216
5. `title_template_in_room`: A template string that can be used to configure the title of the application when viewing a room
218217

219218
#### `title_template` vars
220219

221220
- `$brand` The name of the web app, as configured by the `brand` config value.
222221
- `$room_name` The friendly name of a room. Only applicable to `title_template_in_room`.
223-
- `$status` The client's status, repesented as.
224-
- The notification count, when at least one room is unread.
225-
- "*" when no rooms are unread, but notifications are not muted.
226-
- "Offline", when the client is offline.
227-
- "", when the client isn't logged in or notifications are muted.
222+
- `$status` The client's status, repesented as.
223+
- The notification count, when at least one room is unread.
224+
- "\*" when no rooms are unread, but notifications are not muted.
225+
- "Offline", when the client is offline.
226+
- "", when the client isn't logged in or notifications are muted.
228227

229228
`embedded_pages` can be configured as such:
230229

playwright/e2e/branding/title.spec.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,37 @@ import { expect, test } from "../../element-web-test";
1111
* Tests for branding configuration
1212
**/
1313

14-
test.describe('Test without branding config', () => {
14+
test.describe("Test without branding config", () => {
1515
test("Shows standard branding when showing the home page", async ({ pageWithCredentials: page }) => {
1616
await page.goto("/");
1717
await page.waitForSelector(".mx_MatrixChat", { timeout: 30000 });
18-
expect(page.title()).toEqual('Element *');
18+
expect(page.title()).toEqual("Element *");
1919
});
2020
test("Shows standard branding when showing a room", async ({ app, pageWithCredentials: page }) => {
2121
await app.client.createRoom({ name: "Test Room" });
2222
await app.viewRoomByName("Test Room");
23-
expect(page.title()).toEqual('Element * | Test Room');
23+
expect(page.title()).toEqual("Element * | Test Room");
2424
});
2525
});
2626

27-
test.describe('Test with custom branding', () => {
28-
test.use({ config: {
29-
brand: 'TestBrand',
30-
branding: {
31-
title_template: 'TestingApp $ignoredParameter $brand $status $ignoredParameter',
32-
title_template_in_room: 'TestingApp $brand $status $room_name $ignoredParameter'
33-
}
34-
}});
27+
test.describe("Test with custom branding", () => {
28+
test.use({
29+
config: {
30+
brand: "TestBrand",
31+
branding: {
32+
title_template: "TestingApp $ignoredParameter $brand $status $ignoredParameter",
33+
title_template_in_room: "TestingApp $brand $status $room_name $ignoredParameter",
34+
},
35+
},
36+
});
3537
test("Shows custom branding when showing the home page", async ({ pageWithCredentials: page }) => {
3638
await page.goto("/");
3739
await page.waitForSelector(".mx_MatrixChat", { timeout: 30000 });
38-
expect(page.title()).toEqual('TestingApp TestBrand * $ignoredParameter');
40+
expect(page.title()).toEqual("TestingApp TestBrand * $ignoredParameter");
3941
});
4042
test("Shows custom branding when showing a room", async ({ app, pageWithCredentials: page }) => {
4143
await app.client.createRoom({ name: "Test Room" });
4244
await app.viewRoomByName("Test Room");
43-
expect(page.title()).toEqual('TestingApp TestBrand * Test Room $ignoredParameter');
45+
expect(page.title()).toEqual("TestingApp TestBrand * Test Room $ignoredParameter");
4446
});
4547
});
46-

src/components/structures/MatrixChat.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
285285
// we don't do it as react state as i'm scared about triggering needless react refreshes.
286286
this.subTitleStatus = "";
287287

288-
this.titleTemplate = props.config.branding?.title_template ?? '$brand $status';
289-
this.titleTemplateInRoom = props.config.branding?.title_template_in_room ?? '$brand $status | $room_name';
288+
this.titleTemplate = props.config.branding?.title_template ?? "$brand $status";
289+
this.titleTemplateInRoom = props.config.branding?.title_template_in_room ?? "$brand $status | $room_name";
290290
}
291291

292292
/**
@@ -1961,7 +1961,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
19611961
const params: {
19621962
$brand: string;
19631963
$status: string;
1964-
$room_name: string|undefined;
1964+
$room_name: string | undefined;
19651965
} = {
19661966
$brand: SdkConfig.get().brand,
19671967
$status: this.subTitleStatus,
@@ -1975,14 +1975,16 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
19751975
params.$room_name = room.name;
19761976
}
19771977
}
1978-
1978+
19791979
const titleTemplate = params.$room_name ? this.titleTemplateInRoom : this.titleTemplate;
19801980

19811981
const title = Object.entries(params).reduce(
1982-
(title: string, [key, value]) => title.replaceAll(key, (value ?? '').replaceAll('$', '$_DLR$')), titleTemplate);
1982+
(title: string, [key, value]) => title.replaceAll(key, (value ?? "").replaceAll("$", "$_DLR$")),
1983+
titleTemplate,
1984+
);
19831985

19841986
if (document.title !== title) {
1985-
document.title = title.replaceAll('$_DLR$', '$');
1987+
document.title = title.replaceAll("$_DLR$", "$");
19861988
}
19871989
}
19881990

0 commit comments

Comments
 (0)