Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into t3chguy/dedup-icons-generic
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Oct 14, 2024
2 parents bcd5806 + 03186e4 commit 498e8ba
Show file tree
Hide file tree
Showing 51 changed files with 208 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
backport:
name: Backport
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
if: >
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/end-to-end-tests-netlify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
report:
if: github.event.workflow_run.conclusion != 'cancelled'
name: Report results
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
environment: Netlify
permissions:
statuses: write
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/end-to-end-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ env:
jobs:
build:
name: "Build Element-Web"
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
if: inputs.skip != true
steps:
- name: Checkout code
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
name: "Run Tests ${{ matrix.runner }}/${{ strategy.job-total }}"
needs: build
if: inputs.skip != true
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
permissions:
actions: read
issues: read
Expand Down Expand Up @@ -162,7 +162,7 @@ jobs:
name: end-to-end-tests
needs: playwright
if: always()
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
if: inputs.skip != true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/netlify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
deploy:
if: github.event.workflow_run.conclusion != 'cancelled' && github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
environment: Netlify
steps:
- name: 📝 Create Deployment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/notify-element-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
notify-element-web:
name: "Notify Element Web"
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
# Only respect triggers from our develop branch, ignore that of forks
if: github.repository == 'element-hq/matrix-react-sdk'
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/playwright-image-updates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- cron: "0 6 * * *" # Every day at 6am UTC
jobs:
update:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request_base_branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
jobs:
check_base_branch:
name: Check PR base branch
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/github-script@v7
with:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/static_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
jobs:
ts_lint:
name: "Typescript Syntax Check"
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
rethemendex_lint:
name: "Rethemendex Check"
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand All @@ -77,7 +77,7 @@ jobs:

js_lint:
name: "ESLint"
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand All @@ -95,7 +95,7 @@ jobs:

style_lint:
name: "Style Lint"
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand All @@ -113,7 +113,7 @@ jobs:

workflow_lint:
name: "Workflow Lint"
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand All @@ -131,7 +131,7 @@ jobs:

analyse_dead_code:
name: "Analyse Dead Code"
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ env:
jobs:
jest:
name: Jest
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
name: jest-tests
needs: jest
if: always()
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- if: needs.jest.result != 'skipped' && needs.jest.result != 'success'
run: exit 1
Expand All @@ -111,7 +111,7 @@ jobs:

app-tests:
name: Element Web Integration Tests
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"dependencies": {
"@babel/runtime": "^7.12.5",
"@matrix-org/analytics-events": "^0.26.0",
"@matrix-org/emojibase-bindings": "^1.1.2",
"@matrix-org/emojibase-bindings": "^1.3.3",
"@vector-im/matrix-wysiwyg": "2.37.13",
"@matrix-org/react-sdk-module-api": "^2.4.0",
"@matrix-org/spec": "^1.7.0",
Expand Down
7 changes: 6 additions & 1 deletion playwright/e2e/crypto/crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const testMessages = async (page: Page, bob: Bot, bobRoomId: string) => {
};

const bobJoin = async (page: Page, bob: Bot) => {
// Wait for Bob to get the invite
await bob.evaluate(async (cli) => {
const bobRooms = cli.getRooms();
if (!bobRooms.length) {
Expand All @@ -55,9 +56,13 @@ const bobJoin = async (page: Page, bob: Bot) => {
});
}
});
const roomId = await bob.joinRoomByName("Alice");

const roomId = await bob.joinRoomByName("Alice");
await expect(page.getByText("Bob joined the room")).toBeVisible();

// Even though Alice has seen Bob's join event, Bob may not have done so yet. Wait for the sync to arrive.
await bob.awaitRoomMembership(roomId);

return roomId;
};

Expand Down
9 changes: 6 additions & 3 deletions playwright/e2e/crypto/event-shields.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test.describe("Cryptography", function () {
await app.client.bootstrapCrossSigning(aliceCredentials);
await autoJoin(bob);

// create an encrypted room
// create an encrypted room, and wait for Bob to join it.
testRoomId = await createSharedRoomWithUser(app, bob.credentials.userId, {
name: "TestRoom",
initial_state: [
Expand All @@ -46,6 +46,9 @@ test.describe("Cryptography", function () {
},
],
});

// Even though Alice has seen Bob's join event, Bob may not have done so yet. Wait for the sync to arrive.
await bob.awaitRoomMembership(testRoomId);
});

test("should show the correct shield on e2e events", async ({
Expand Down Expand Up @@ -287,9 +290,9 @@ test.describe("Cryptography", function () {
// Let our app start syncing again
await app.client.network.goOnline();

// Wait for the messages to arrive
// Wait for the messages to arrive. It can take quite a while for the sync to wake up.
const last = page.locator(".mx_EventTile_last");
await expect(last).toContainText("test encrypted from unverified");
await expect(last).toContainText("test encrypted from unverified", { timeout: 20000 });
const lastE2eIcon = last.locator(".mx_EventTile_e2eIcon");
await expect(lastE2eIcon).toHaveClass(/mx_EventTile_e2eIcon_warning/);
await lastE2eIcon.focus();
Expand Down
8 changes: 8 additions & 0 deletions playwright/e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ import { Client } from "../pages/client";
* @param client Client instance that can be user or bot
* @param roomId room id to find room and check
* @param predicate defines condition that is used to check the room state
*
* FIXME this does not do what it is supposed to do, and I think it is unfixable.
* `page.exposeFunction` adds a function which returns a Promise. `window[predicateId](room)` therefore
* always returns a truthy value (a Promise). But even if you fix that: as far as I can tell, the Room is
* just passed to the callback function as a JSON blob: you cannot actually call any methods on it, so the
* callback is useless.
*
* @deprecated This function is broken.
*/
export async function waitForRoom(
page: Page,
Expand Down
48 changes: 48 additions & 0 deletions playwright/pages/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,54 @@ export class Client {
await client.evaluate((client, { roomId, userId }) => client.unban(roomId, userId), { roomId, userId });
}

/**
* Wait for the client to have specific membership of a given room
*
* This is often useful after joining a room, when we need to wait for the sync loop to catch up.
*
* Times out with an error after 1 second.
*
* @param roomId - ID of the room to check
* @param membership - required membership.
*/
public async awaitRoomMembership(roomId: string, membership: string = "join") {
await this.evaluate(
(cli: MatrixClient, { roomId, membership }) => {
const isReady = () => {
// Fetch the room on each check, because we get a different instance before and after the join arrives.
const room = cli.getRoom(roomId);
const myMembership = room?.getMyMembership();
// @ts-ignore access to private field "logger"
cli.logger.info(`waiting for room ${roomId}: membership now ${myMembership}`);
return myMembership === membership;
};
if (isReady()) return;

const timeoutPromise = new Promise((resolve) => setTimeout(resolve, 1000)).then(() => {
const room = cli.getRoom(roomId);
const myMembership = room?.getMyMembership();
throw new Error(
`Timeout waiting for room ${roomId} membership (now '${myMembership}', wanted '${membership}')`,
);
});

const readyPromise = new Promise<void>((resolve) => {
async function onEvent() {
if (isReady()) {
cli.removeListener(window.matrixcs.ClientEvent.Event, onEvent);
resolve();
}
}

cli.on(window.matrixcs.ClientEvent.Event, onEvent);
});

return Promise.race([timeoutPromise, readyPromise]);
},
{ roomId, membership },
);
}

/**
* @param {MatrixEvent} event
* @param {ReceiptType} receiptType
Expand Down
3 changes: 3 additions & 0 deletions res/css/structures/auth/_MobileRegistration.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ Please see LICENSE files in the repository root for full details.

.mx_MobileRegister_body {
padding: 32px;
height: 100vh;
overflow-y: auto;
box-sizing: border-box;
}
2 changes: 0 additions & 2 deletions src/MatrixClientPeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { formatList } from "./utils/FormattingUtils";
import SdkConfig from "./SdkConfig";
import { Features } from "./settings/Settings";
import { setDeviceIsolationMode } from "./settings/controllers/DeviceIsolationModeController.ts";
import { ReadyWatchingStore } from "./stores/ReadyWatchingStore.ts";

export interface IMatrixClientCreds {
homeserverUrl: string;
Expand Down Expand Up @@ -310,7 +309,6 @@ class MatrixClientPegClass implements IMatrixClientPeg {
MatrixActionCreators.start(this.matrixClient);
MatrixClientBackedSettingsHandler.matrixClient = this.matrixClient;
MatrixClientBackedController.matrixClient = this.matrixClient;
ReadyWatchingStore.matrixClient = this.matrixClient;

return opts;
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/views/rooms/BasicMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
// so xd will not match if the string was "mixd 123456"
// and we are lookinh at xd 123456 part of the string
if (emoticonMatch && (n >= 0 || emoticonMatch.index !== 0)) {
const query = emoticonMatch[1].replace("-", "");
// try both exact match and lower-case, this means that xd won't match xD but :P will match :p
const data = EMOTICON_TO_EMOJI.get(query) || EMOTICON_TO_EMOJI.get(query.toLowerCase());
const query = emoticonMatch[1];
// variations of plaintext emoitcons(E.g. :P vs :p vs :-P) are handled upstream by the emojibase-bindings library
const data = EMOTICON_TO_EMOJI.get(query);

if (data) {
const { partCreator } = model;
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/rooms/EventTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ class E2ePadlock extends React.Component<IE2ePadlockProps> {
// https://github.com/element-hq/compound/issues/294
return (
<Tooltip label={this.props.title} isTriggerInteractive={true}>
<div className={classes} tabIndex={0} />
<div className={classes} tabIndex={0} aria-label={_t("timeline|e2e_state")} />
</Tooltip>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ function shouldIncrementEndIndex(text: string, index: number): boolean {
*/
export function getMappedSuggestion(text: string, isAutoReplaceEmojiEnabled?: boolean): MappedSuggestion | null {
if (isAutoReplaceEmojiEnabled) {
const emoji = EMOTICON_TO_EMOJI.get(text.toLocaleLowerCase());
// variations of plaintext emoitcons(E.g. :P vs :p vs :-P) are handled upstream by the emojibase-bindings/emojibase libraries.
// See rules for variations here https://github.com/milesj/emojibase/blob/master/packages/core/src/generateEmoticonPermutations.ts#L3-L32
const emoji = EMOTICON_TO_EMOJI.get(text);
if (emoji?.unicode) {
return { keyChar: "", text: emoji.unicode, type: "custom" };
}
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -3272,6 +3272,7 @@
"download_action_downloading": "Downloading",
"download_failed": "Download failed",
"download_failed_description": "An error occurred while downloading this file",
"e2e_state": "State of the end-to-end encryption",
"edits": {
"tooltip_label": "Edited at %(date)s. Click to view edits.",
"tooltip_sub": "Click to view edits",
Expand Down
9 changes: 2 additions & 7 deletions src/stores/AsyncStoreWithClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,8 @@ export abstract class AsyncStoreWithClient<T extends Object> extends AsyncStore<
})(dispatcher);
}

protected async start(matrixClient: MatrixClient | null): Promise<void> {
await this.readyStore.start(matrixClient);
}

// XXX: This method is intended only for use in tests.
public async useUnitTestClient(cli: MatrixClient): Promise<void> {
await this.readyStore.useUnitTestClient(cli);
public async start(): Promise<void> {
await this.readyStore.start();
}

public get matrixClient(): MatrixClient | null {
Expand Down
4 changes: 3 additions & 1 deletion src/stores/AutoRageshakeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ interface IState {
*/
export default class AutoRageshakeStore extends AsyncStoreWithClient<IState> {
private static readonly internalInstance = (() => {
return new AutoRageshakeStore();
const instance = new AutoRageshakeStore();
instance.start();
return instance;
})();

private constructor() {
Expand Down
4 changes: 3 additions & 1 deletion src/stores/BreadcrumbsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ interface IState {

export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
private static readonly internalInstance = (() => {
return new BreadcrumbsStore();
const instance = new BreadcrumbsStore();
instance.start();
return instance;
})();

private waitingRooms: { roomId: string; addedTs: number }[] = [];
Expand Down
Loading

0 comments on commit 498e8ba

Please sign in to comment.