mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-06 06:28:27 +00:00
Merge branch 'develop' into t3chguy/dedup-icons-generic
This commit is contained in:
@@ -10,7 +10,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
backport:
|
backport:
|
||||||
name: Backport
|
name: Backport
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
# Only react to merged PRs for security reasons.
|
# Only react to merged PRs for security reasons.
|
||||||
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
|
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
|
||||||
if: >
|
if: >
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ jobs:
|
|||||||
report:
|
report:
|
||||||
if: github.event.workflow_run.conclusion != 'cancelled'
|
if: github.event.workflow_run.conclusion != 'cancelled'
|
||||||
name: Report results
|
name: Report results
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
environment: Netlify
|
environment: Netlify
|
||||||
permissions:
|
permissions:
|
||||||
statuses: write
|
statuses: write
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: "Build Element-Web"
|
name: "Build Element-Web"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
if: inputs.skip != true
|
if: inputs.skip != true
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -95,7 +95,7 @@ jobs:
|
|||||||
name: "Run Tests ${{ matrix.runner }}/${{ strategy.job-total }}"
|
name: "Run Tests ${{ matrix.runner }}/${{ strategy.job-total }}"
|
||||||
needs: build
|
needs: build
|
||||||
if: inputs.skip != true
|
if: inputs.skip != true
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
permissions:
|
permissions:
|
||||||
actions: read
|
actions: read
|
||||||
issues: read
|
issues: read
|
||||||
@@ -162,7 +162,7 @@ jobs:
|
|||||||
name: end-to-end-tests
|
name: end-to-end-tests
|
||||||
needs: playwright
|
needs: playwright
|
||||||
if: always()
|
if: always()
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
if: inputs.skip != true
|
if: inputs.skip != true
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
if: github.event.workflow_run.conclusion != 'cancelled' && github.event.workflow_run.event == 'pull_request'
|
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
|
environment: Netlify
|
||||||
steps:
|
steps:
|
||||||
- name: 📝 Create Deployment
|
- name: 📝 Create Deployment
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
notify-element-web:
|
notify-element-web:
|
||||||
name: "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
|
# Only respect triggers from our develop branch, ignore that of forks
|
||||||
if: github.repository == 'element-hq/matrix-react-sdk'
|
if: github.repository == 'element-hq/matrix-react-sdk'
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ on:
|
|||||||
- cron: "0 6 * * *" # Every day at 6am UTC
|
- cron: "0 6 * * *" # Every day at 6am UTC
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
check_base_branch:
|
check_base_branch:
|
||||||
name: Check PR base branch
|
name: Check PR base branch
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@v7
|
- uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
ts_lint:
|
ts_lint:
|
||||||
name: "Typescript Syntax Check"
|
name: "Typescript Syntax Check"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ jobs:
|
|||||||
|
|
||||||
rethemendex_lint:
|
rethemendex_lint:
|
||||||
name: "Rethemendex Check"
|
name: "Rethemendex Check"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ jobs:
|
|||||||
|
|
||||||
js_lint:
|
js_lint:
|
||||||
name: "ESLint"
|
name: "ESLint"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ jobs:
|
|||||||
|
|
||||||
style_lint:
|
style_lint:
|
||||||
name: "Style Lint"
|
name: "Style Lint"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ jobs:
|
|||||||
|
|
||||||
workflow_lint:
|
workflow_lint:
|
||||||
name: "Workflow Lint"
|
name: "Workflow Lint"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ jobs:
|
|||||||
|
|
||||||
analyse_dead_code:
|
analyse_dead_code:
|
||||||
name: "Analyse Dead Code"
|
name: "Analyse Dead Code"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
jest:
|
jest:
|
||||||
name: Jest
|
name: Jest
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -93,7 +93,7 @@ jobs:
|
|||||||
name: jest-tests
|
name: jest-tests
|
||||||
needs: jest
|
needs: jest
|
||||||
if: always()
|
if: always()
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- if: needs.jest.result != 'skipped' && needs.jest.result != 'success'
|
- if: needs.jest.result != 'skipped' && needs.jest.result != 'success'
|
||||||
run: exit 1
|
run: exit 1
|
||||||
@@ -111,7 +111,7 @@ jobs:
|
|||||||
|
|
||||||
app-tests:
|
app-tests:
|
||||||
name: Element Web Integration Tests
|
name: Element Web Integration Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.12.5",
|
||||||
"@matrix-org/analytics-events": "^0.26.0",
|
"@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",
|
"@vector-im/matrix-wysiwyg": "2.37.13",
|
||||||
"@matrix-org/react-sdk-module-api": "^2.4.0",
|
"@matrix-org/react-sdk-module-api": "^2.4.0",
|
||||||
"@matrix-org/spec": "^1.7.0",
|
"@matrix-org/spec": "^1.7.0",
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ const testMessages = async (page: Page, bob: Bot, bobRoomId: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const bobJoin = async (page: Page, bob: Bot) => {
|
const bobJoin = async (page: Page, bob: Bot) => {
|
||||||
|
// Wait for Bob to get the invite
|
||||||
await bob.evaluate(async (cli) => {
|
await bob.evaluate(async (cli) => {
|
||||||
const bobRooms = cli.getRooms();
|
const bobRooms = cli.getRooms();
|
||||||
if (!bobRooms.length) {
|
if (!bobRooms.length) {
|
||||||
@@ -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();
|
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;
|
return roomId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ test.describe("Cryptography", function () {
|
|||||||
await app.client.bootstrapCrossSigning(aliceCredentials);
|
await app.client.bootstrapCrossSigning(aliceCredentials);
|
||||||
await autoJoin(bob);
|
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, {
|
testRoomId = await createSharedRoomWithUser(app, bob.credentials.userId, {
|
||||||
name: "TestRoom",
|
name: "TestRoom",
|
||||||
initial_state: [
|
initial_state: [
|
||||||
@@ -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 ({
|
test("should show the correct shield on e2e events", async ({
|
||||||
@@ -287,9 +290,9 @@ test.describe("Cryptography", function () {
|
|||||||
// Let our app start syncing again
|
// Let our app start syncing again
|
||||||
await app.client.network.goOnline();
|
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");
|
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");
|
const lastE2eIcon = last.locator(".mx_EventTile_e2eIcon");
|
||||||
await expect(lastE2eIcon).toHaveClass(/mx_EventTile_e2eIcon_warning/);
|
await expect(lastE2eIcon).toHaveClass(/mx_EventTile_e2eIcon_warning/);
|
||||||
await lastE2eIcon.focus();
|
await lastE2eIcon.focus();
|
||||||
|
|||||||
@@ -20,6 +20,14 @@ import { Client } from "../pages/client";
|
|||||||
* @param client Client instance that can be user or bot
|
* @param client Client instance that can be user or bot
|
||||||
* @param roomId room id to find room and check
|
* @param roomId room id to find room and check
|
||||||
* @param predicate defines condition that is used to check the room state
|
* @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(
|
export async function waitForRoom(
|
||||||
page: Page,
|
page: Page,
|
||||||
|
|||||||
@@ -289,6 +289,54 @@ export class Client {
|
|||||||
await client.evaluate((client, { roomId, userId }) => client.unban(roomId, userId), { roomId, userId });
|
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 {MatrixEvent} event
|
||||||
* @param {ReceiptType} receiptType
|
* @param {ReceiptType} receiptType
|
||||||
|
|||||||
@@ -7,4 +7,7 @@ Please see LICENSE files in the repository root for full details.
|
|||||||
|
|
||||||
.mx_MobileRegister_body {
|
.mx_MobileRegister_body {
|
||||||
padding: 32px;
|
padding: 32px;
|
||||||
|
height: 100vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import { formatList } from "./utils/FormattingUtils";
|
|||||||
import SdkConfig from "./SdkConfig";
|
import SdkConfig from "./SdkConfig";
|
||||||
import { Features } from "./settings/Settings";
|
import { Features } from "./settings/Settings";
|
||||||
import { setDeviceIsolationMode } from "./settings/controllers/DeviceIsolationModeController.ts";
|
import { setDeviceIsolationMode } from "./settings/controllers/DeviceIsolationModeController.ts";
|
||||||
import { ReadyWatchingStore } from "./stores/ReadyWatchingStore.ts";
|
|
||||||
|
|
||||||
export interface IMatrixClientCreds {
|
export interface IMatrixClientCreds {
|
||||||
homeserverUrl: string;
|
homeserverUrl: string;
|
||||||
@@ -310,7 +309,6 @@ class MatrixClientPegClass implements IMatrixClientPeg {
|
|||||||
MatrixActionCreators.start(this.matrixClient);
|
MatrixActionCreators.start(this.matrixClient);
|
||||||
MatrixClientBackedSettingsHandler.matrixClient = this.matrixClient;
|
MatrixClientBackedSettingsHandler.matrixClient = this.matrixClient;
|
||||||
MatrixClientBackedController.matrixClient = this.matrixClient;
|
MatrixClientBackedController.matrixClient = this.matrixClient;
|
||||||
ReadyWatchingStore.matrixClient = this.matrixClient;
|
|
||||||
|
|
||||||
return opts;
|
return opts;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,9 +201,9 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
|
|||||||
// so xd will not match if the string was "mixd 123456"
|
// so xd will not match if the string was "mixd 123456"
|
||||||
// and we are lookinh at xd 123456 part of the string
|
// and we are lookinh at xd 123456 part of the string
|
||||||
if (emoticonMatch && (n >= 0 || emoticonMatch.index !== 0)) {
|
if (emoticonMatch && (n >= 0 || emoticonMatch.index !== 0)) {
|
||||||
const query = emoticonMatch[1].replace("-", "");
|
const query = emoticonMatch[1];
|
||||||
// try both exact match and lower-case, this means that xd won't match xD but :P will match :p
|
// 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) || EMOTICON_TO_EMOJI.get(query.toLowerCase());
|
const data = EMOTICON_TO_EMOJI.get(query);
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
const { partCreator } = model;
|
const { partCreator } = model;
|
||||||
|
|||||||
@@ -1519,7 +1519,7 @@ class E2ePadlock extends React.Component<IE2ePadlockProps> {
|
|||||||
// https://github.com/element-hq/compound/issues/294
|
// https://github.com/element-hq/compound/issues/294
|
||||||
return (
|
return (
|
||||||
<Tooltip label={this.props.title} isTriggerInteractive={true}>
|
<Tooltip label={this.props.title} isTriggerInteractive={true}>
|
||||||
<div className={classes} tabIndex={0} />
|
<div className={classes} tabIndex={0} aria-label={_t("timeline|e2e_state")} />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -388,7 +388,9 @@ function shouldIncrementEndIndex(text: string, index: number): boolean {
|
|||||||
*/
|
*/
|
||||||
export function getMappedSuggestion(text: string, isAutoReplaceEmojiEnabled?: boolean): MappedSuggestion | null {
|
export function getMappedSuggestion(text: string, isAutoReplaceEmojiEnabled?: boolean): MappedSuggestion | null {
|
||||||
if (isAutoReplaceEmojiEnabled) {
|
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) {
|
if (emoji?.unicode) {
|
||||||
return { keyChar: "", text: emoji.unicode, type: "custom" };
|
return { keyChar: "", text: emoji.unicode, type: "custom" };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3272,6 +3272,7 @@
|
|||||||
"download_action_downloading": "Downloading",
|
"download_action_downloading": "Downloading",
|
||||||
"download_failed": "Download failed",
|
"download_failed": "Download failed",
|
||||||
"download_failed_description": "An error occurred while downloading this file",
|
"download_failed_description": "An error occurred while downloading this file",
|
||||||
|
"e2e_state": "State of the end-to-end encryption",
|
||||||
"edits": {
|
"edits": {
|
||||||
"tooltip_label": "Edited at %(date)s. Click to view edits.",
|
"tooltip_label": "Edited at %(date)s. Click to view edits.",
|
||||||
"tooltip_sub": "Click to view edits",
|
"tooltip_sub": "Click to view edits",
|
||||||
|
|||||||
@@ -36,13 +36,8 @@ export abstract class AsyncStoreWithClient<T extends Object> extends AsyncStore<
|
|||||||
})(dispatcher);
|
})(dispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async start(matrixClient: MatrixClient | null): Promise<void> {
|
public async start(): Promise<void> {
|
||||||
await this.readyStore.start(matrixClient);
|
await this.readyStore.start();
|
||||||
}
|
|
||||||
|
|
||||||
// XXX: This method is intended only for use in tests.
|
|
||||||
public async useUnitTestClient(cli: MatrixClient): Promise<void> {
|
|
||||||
await this.readyStore.useUnitTestClient(cli);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public get matrixClient(): MatrixClient | null {
|
public get matrixClient(): MatrixClient | null {
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ interface IState {
|
|||||||
*/
|
*/
|
||||||
export default class AutoRageshakeStore extends AsyncStoreWithClient<IState> {
|
export default class AutoRageshakeStore extends AsyncStoreWithClient<IState> {
|
||||||
private static readonly internalInstance = (() => {
|
private static readonly internalInstance = (() => {
|
||||||
return new AutoRageshakeStore();
|
const instance = new AutoRageshakeStore();
|
||||||
|
instance.start();
|
||||||
|
return instance;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ interface IState {
|
|||||||
|
|
||||||
export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
|
export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
|
||||||
private static readonly internalInstance = (() => {
|
private static readonly internalInstance = (() => {
|
||||||
return new BreadcrumbsStore();
|
const instance = new BreadcrumbsStore();
|
||||||
|
instance.start();
|
||||||
|
return instance;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
private waitingRooms: { roomId: string; addedTs: number }[] = [];
|
private waitingRooms: { roomId: string; addedTs: number }[] = [];
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export class CallStore extends AsyncStoreWithClient<{}> {
|
|||||||
public static get instance(): CallStore {
|
public static get instance(): CallStore {
|
||||||
if (!this._instance) {
|
if (!this._instance) {
|
||||||
this._instance = new CallStore();
|
this._instance = new CallStore();
|
||||||
|
this._instance.start();
|
||||||
}
|
}
|
||||||
return this._instance;
|
return this._instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ interface IState {
|
|||||||
export class ModalWidgetStore extends AsyncStoreWithClient<IState> {
|
export class ModalWidgetStore extends AsyncStoreWithClient<IState> {
|
||||||
private static readonly internalInstance = (() => {
|
private static readonly internalInstance = (() => {
|
||||||
const instance = new ModalWidgetStore();
|
const instance = new ModalWidgetStore();
|
||||||
|
instance.start();
|
||||||
return instance;
|
return instance;
|
||||||
})();
|
})();
|
||||||
private modalInstance: IHandle<typeof ModalWidgetDialog> | null = null;
|
private modalInstance: IHandle<typeof ModalWidgetDialog> | null = null;
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ const getLocallyCreatedBeaconEventIds = (): string[] => {
|
|||||||
export class OwnBeaconStore extends AsyncStoreWithClient<OwnBeaconStoreState> {
|
export class OwnBeaconStore extends AsyncStoreWithClient<OwnBeaconStoreState> {
|
||||||
private static readonly internalInstance = (() => {
|
private static readonly internalInstance = (() => {
|
||||||
const instance = new OwnBeaconStore();
|
const instance = new OwnBeaconStore();
|
||||||
|
instance.start();
|
||||||
return instance;
|
return instance;
|
||||||
})();
|
})();
|
||||||
// users beacons, keyed by event type
|
// users beacons, keyed by event type
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const KEY_AVATAR_URL = "mx_profile_avatar_url";
|
|||||||
export class OwnProfileStore extends AsyncStoreWithClient<IState> {
|
export class OwnProfileStore extends AsyncStoreWithClient<IState> {
|
||||||
private static readonly internalInstance = (() => {
|
private static readonly internalInstance = (() => {
|
||||||
const instance = new OwnProfileStore();
|
const instance = new OwnProfileStore();
|
||||||
|
instance.start();
|
||||||
return instance;
|
return instance;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@@ -9,40 +9,27 @@
|
|||||||
import { MatrixClient, SyncState } from "matrix-js-sdk/src/matrix";
|
import { MatrixClient, SyncState } from "matrix-js-sdk/src/matrix";
|
||||||
import { EventEmitter } from "events";
|
import { EventEmitter } from "events";
|
||||||
|
|
||||||
|
import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||||
import { ActionPayload } from "../dispatcher/payloads";
|
import { ActionPayload } from "../dispatcher/payloads";
|
||||||
import { IDestroyable } from "../utils/IDestroyable";
|
import { IDestroyable } from "../utils/IDestroyable";
|
||||||
import { Action } from "../dispatcher/actions";
|
import { Action } from "../dispatcher/actions";
|
||||||
import { MatrixDispatcher } from "../dispatcher/dispatcher";
|
import { MatrixDispatcher } from "../dispatcher/dispatcher";
|
||||||
|
|
||||||
export abstract class ReadyWatchingStore extends EventEmitter implements IDestroyable {
|
export abstract class ReadyWatchingStore extends EventEmitter implements IDestroyable {
|
||||||
private static instances: ReadyWatchingStore[] = [];
|
protected matrixClient: MatrixClient | null = null;
|
||||||
protected _matrixClient: MatrixClient | null = null;
|
|
||||||
private dispatcherRef: string | null = null;
|
private dispatcherRef: string | null = null;
|
||||||
|
|
||||||
public static set matrixClient(client: MatrixClient) {
|
|
||||||
for (const instance of ReadyWatchingStore.instances) {
|
|
||||||
instance.start(client);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public constructor(protected readonly dispatcher: MatrixDispatcher) {
|
public constructor(protected readonly dispatcher: MatrixDispatcher) {
|
||||||
super();
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async start(): Promise<void> {
|
||||||
this.dispatcherRef = this.dispatcher.register(this.onAction);
|
this.dispatcherRef = this.dispatcher.register(this.onAction);
|
||||||
}
|
|
||||||
|
|
||||||
public get matrixClient(): MatrixClient | null {
|
// MatrixClientPeg can be undefined in tests because of circular dependencies with other stores
|
||||||
return this._matrixClient;
|
const matrixClient = MatrixClientPeg?.get();
|
||||||
}
|
|
||||||
|
|
||||||
public async start(matrixClient: MatrixClient | null): Promise<void> {
|
|
||||||
const oldClient = this._matrixClient;
|
|
||||||
this._matrixClient = matrixClient;
|
|
||||||
|
|
||||||
if (oldClient !== matrixClient) {
|
|
||||||
await this.onNotReady();
|
|
||||||
}
|
|
||||||
if (matrixClient) {
|
if (matrixClient) {
|
||||||
|
this.matrixClient = matrixClient;
|
||||||
await this.onReady();
|
await this.onReady();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,10 +38,8 @@ export abstract class ReadyWatchingStore extends EventEmitter implements IDestro
|
|||||||
return this.matrixClient; // for external readonly access
|
return this.matrixClient; // for external readonly access
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: This method is intended only for use in tests.
|
public useUnitTestClient(cli: MatrixClient): void {
|
||||||
public async useUnitTestClient(cli: MatrixClient): Promise<void> {
|
this.matrixClient = cli;
|
||||||
this._matrixClient = cli;
|
|
||||||
await this.onReady();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public destroy(): void {
|
public destroy(): void {
|
||||||
@@ -89,13 +74,13 @@ export abstract class ReadyWatchingStore extends EventEmitter implements IDestro
|
|||||||
if (this.matrixClient) {
|
if (this.matrixClient) {
|
||||||
await this.onNotReady();
|
await this.onNotReady();
|
||||||
}
|
}
|
||||||
this._matrixClient = payload.matrixClient;
|
this.matrixClient = payload.matrixClient;
|
||||||
await this.onReady();
|
await this.onReady();
|
||||||
}
|
}
|
||||||
} else if (payload.action === "on_client_not_viable" || payload.action === Action.OnLoggedOut) {
|
} else if (payload.action === "on_client_not_viable" || payload.action === Action.OnLoggedOut) {
|
||||||
if (this.matrixClient) {
|
if (this.matrixClient) {
|
||||||
await this.onNotReady();
|
await this.onNotReady();
|
||||||
this._matrixClient = null;
|
this.matrixClient = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export class VoiceRecordingStore extends AsyncStoreWithClient<IState> {
|
|||||||
public static get instance(): VoiceRecordingStore {
|
public static get instance(): VoiceRecordingStore {
|
||||||
if (!this.internalInstance) {
|
if (!this.internalInstance) {
|
||||||
this.internalInstance = new VoiceRecordingStore();
|
this.internalInstance = new VoiceRecordingStore();
|
||||||
|
this.internalInstance.start();
|
||||||
}
|
}
|
||||||
return this.internalInstance;
|
return this.internalInstance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ interface IRoomWidgets {
|
|||||||
export default class WidgetStore extends AsyncStoreWithClient<IState> {
|
export default class WidgetStore extends AsyncStoreWithClient<IState> {
|
||||||
private static readonly internalInstance = (() => {
|
private static readonly internalInstance = (() => {
|
||||||
const instance = new WidgetStore();
|
const instance = new WidgetStore();
|
||||||
|
instance.start();
|
||||||
return instance;
|
return instance;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export class EchoStore extends AsyncStoreWithClient<IState> {
|
|||||||
public static get instance(): EchoStore {
|
public static get instance(): EchoStore {
|
||||||
if (!this._instance) {
|
if (!this._instance) {
|
||||||
this._instance = new EchoStore();
|
this._instance = new EchoStore();
|
||||||
|
this._instance.start();
|
||||||
}
|
}
|
||||||
return this._instance;
|
return this._instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export const UPDATE_STATUS_INDICATOR = Symbol("update-status-indicator");
|
|||||||
export class RoomNotificationStateStore extends AsyncStoreWithClient<IState> {
|
export class RoomNotificationStateStore extends AsyncStoreWithClient<IState> {
|
||||||
private static readonly internalInstance = (() => {
|
private static readonly internalInstance = (() => {
|
||||||
const instance = new RoomNotificationStateStore();
|
const instance = new RoomNotificationStateStore();
|
||||||
|
instance.start();
|
||||||
return instance;
|
return instance;
|
||||||
})();
|
})();
|
||||||
private roomMap = new Map<Room, RoomNotificationState>();
|
private roomMap = new Map<Room, RoomNotificationState>();
|
||||||
|
|||||||
@@ -403,6 +403,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
|
|||||||
public static get instance(): RightPanelStore {
|
public static get instance(): RightPanelStore {
|
||||||
if (!this.internalInstance) {
|
if (!this.internalInstance) {
|
||||||
this.internalInstance = new RightPanelStore();
|
this.internalInstance = new RightPanelStore();
|
||||||
|
this.internalInstance.start();
|
||||||
}
|
}
|
||||||
return this.internalInstance;
|
return this.internalInstance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,11 @@ const mkMessagePreview = (text: string, event: MatrixEvent): MessagePreview => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export class MessagePreviewStore extends AsyncStoreWithClient<IState> {
|
export class MessagePreviewStore extends AsyncStoreWithClient<IState> {
|
||||||
private static readonly internalInstance = (() => new MessagePreviewStore())();
|
private static readonly internalInstance = (() => {
|
||||||
|
const instance = new MessagePreviewStore();
|
||||||
|
instance.start();
|
||||||
|
return instance;
|
||||||
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal Public for test only
|
* @internal Public for test only
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export default class RoomListLayoutStore extends AsyncStoreWithClient<IState> {
|
|||||||
public static get instance(): RoomListLayoutStore {
|
public static get instance(): RoomListLayoutStore {
|
||||||
if (!this.internalInstance) {
|
if (!this.internalInstance) {
|
||||||
this.internalInstance = new RoomListLayoutStore();
|
this.internalInstance = new RoomListLayoutStore();
|
||||||
|
this.internalInstance.start();
|
||||||
}
|
}
|
||||||
return RoomListLayoutStore.internalInstance;
|
return RoomListLayoutStore.internalInstance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -643,9 +643,11 @@ export default class RoomListStore {
|
|||||||
if (SettingsStore.getValue("feature_sliding_sync")) {
|
if (SettingsStore.getValue("feature_sliding_sync")) {
|
||||||
logger.info("using SlidingRoomListStoreClass");
|
logger.info("using SlidingRoomListStoreClass");
|
||||||
const instance = new SlidingRoomListStoreClass(defaultDispatcher, SdkContextClass.instance);
|
const instance = new SlidingRoomListStoreClass(defaultDispatcher, SdkContextClass.instance);
|
||||||
|
instance.start();
|
||||||
RoomListStore.internalInstance = instance;
|
RoomListStore.internalInstance = instance;
|
||||||
} else {
|
} else {
|
||||||
const instance = new RoomListStoreClass(defaultDispatcher);
|
const instance = new RoomListStoreClass(defaultDispatcher);
|
||||||
|
instance.start();
|
||||||
RoomListStore.internalInstance = instance;
|
RoomListStore.internalInstance = instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import {
|
|||||||
MatrixEvent,
|
MatrixEvent,
|
||||||
ClientEvent,
|
ClientEvent,
|
||||||
ISendEventResponse,
|
ISendEventResponse,
|
||||||
MatrixClient,
|
|
||||||
} from "matrix-js-sdk/src/matrix";
|
} from "matrix-js-sdk/src/matrix";
|
||||||
import { KnownMembership } from "matrix-js-sdk/src/types";
|
import { KnownMembership } from "matrix-js-sdk/src/types";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
@@ -1398,6 +1397,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
|||||||
export default class SpaceStore {
|
export default class SpaceStore {
|
||||||
private static readonly internalInstance = (() => {
|
private static readonly internalInstance = (() => {
|
||||||
const instance = new SpaceStoreClass();
|
const instance = new SpaceStoreClass();
|
||||||
|
instance.start();
|
||||||
return instance;
|
return instance;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -1408,9 +1408,9 @@ export default class SpaceStore {
|
|||||||
/**
|
/**
|
||||||
* @internal for test only
|
* @internal for test only
|
||||||
*/
|
*/
|
||||||
public static testInstance(client: MatrixClient): SpaceStoreClass {
|
public static testInstance(): SpaceStoreClass {
|
||||||
const store = new SpaceStoreClass();
|
const store = new SpaceStoreClass();
|
||||||
store.useUnitTestClient(client);
|
store.start();
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ export class WidgetLayoutStore extends ReadyWatchingStore {
|
|||||||
public static get instance(): WidgetLayoutStore {
|
public static get instance(): WidgetLayoutStore {
|
||||||
if (!this.internalInstance) {
|
if (!this.internalInstance) {
|
||||||
this.internalInstance = new WidgetLayoutStore();
|
this.internalInstance = new WidgetLayoutStore();
|
||||||
|
this.internalInstance.start();
|
||||||
}
|
}
|
||||||
return this.internalInstance;
|
return this.internalInstance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export enum WidgetMessagingStoreEvent {
|
|||||||
export class WidgetMessagingStore extends AsyncStoreWithClient<{}> {
|
export class WidgetMessagingStore extends AsyncStoreWithClient<{}> {
|
||||||
private static readonly internalInstance = (() => {
|
private static readonly internalInstance = (() => {
|
||||||
const instance = new WidgetMessagingStore();
|
const instance = new WidgetMessagingStore();
|
||||||
|
instance.start();
|
||||||
return instance;
|
return instance;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@@ -66,15 +66,29 @@ export const SESSION_LOCK_CONSTANTS = {
|
|||||||
* @returns true if any instance is currently active
|
* @returns true if any instance is currently active
|
||||||
*/
|
*/
|
||||||
export function checkSessionLockFree(): boolean {
|
export function checkSessionLockFree(): boolean {
|
||||||
|
const prefixedLogger = logger.getChild(`checkSessionLockFree`);
|
||||||
|
|
||||||
const lastPingTime = window.localStorage.getItem(SESSION_LOCK_CONSTANTS.STORAGE_ITEM_PING);
|
const lastPingTime = window.localStorage.getItem(SESSION_LOCK_CONSTANTS.STORAGE_ITEM_PING);
|
||||||
if (lastPingTime === null) {
|
if (lastPingTime === null) {
|
||||||
// no other holder
|
// no other holder
|
||||||
|
prefixedLogger.info("No other session has the lock");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const lockHolder = window.localStorage.getItem(SESSION_LOCK_CONSTANTS.STORAGE_ITEM_OWNER);
|
||||||
|
|
||||||
// see if it has expired
|
// see if it has expired
|
||||||
const timeAgo = Date.now() - parseInt(lastPingTime);
|
const timeAgo = Date.now() - parseInt(lastPingTime);
|
||||||
return timeAgo > SESSION_LOCK_CONSTANTS.LOCK_EXPIRY_TIME_MS;
|
|
||||||
|
const remaining = SESSION_LOCK_CONSTANTS.LOCK_EXPIRY_TIME_MS - timeAgo;
|
||||||
|
if (remaining <= 0) {
|
||||||
|
// another session claimed the lock, but it is stale.
|
||||||
|
prefixedLogger.info(`Last ping (from ${lockHolder}) was ${timeAgo}ms ago: lock is free`);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
prefixedLogger.info(`Last ping (from ${lockHolder}) was ${timeAgo}ms ago: lock is taken`);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,7 +109,7 @@ export async function getSessionLock(onNewInstance: () => Promise<void>): Promis
|
|||||||
/** unique ID for this session */
|
/** unique ID for this session */
|
||||||
const sessionIdentifier = uuidv4();
|
const sessionIdentifier = uuidv4();
|
||||||
|
|
||||||
const prefixedLogger = logger.withPrefix(`getSessionLock[${sessionIdentifier}]`);
|
const prefixedLogger = logger.getChild(`getSessionLock[${sessionIdentifier}]`);
|
||||||
|
|
||||||
/** The ID of our regular task to service the lock.
|
/** The ID of our regular task to service the lock.
|
||||||
*
|
*
|
||||||
@@ -133,7 +147,7 @@ export async function getSessionLock(onNewInstance: () => Promise<void>): Promis
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
prefixedLogger.info(`Last ping (from ${lockHolder}) was ${timeAgo}ms ago, waiting`);
|
prefixedLogger.info(`Last ping (from ${lockHolder}) was ${timeAgo}ms ago, waiting ${remaining}ms`);
|
||||||
return remaining;
|
return remaining;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ describe("BasicMessageComposer", () => {
|
|||||||
{ before: ":-D", after: "😄" },
|
{ before: ":-D", after: "😄" },
|
||||||
{ before: ":D", after: "😄" },
|
{ before: ":D", after: "😄" },
|
||||||
{ before: ":3", after: "😽" },
|
{ before: ":3", after: "😽" },
|
||||||
|
{ before: "=-]", after: "🙂" },
|
||||||
];
|
];
|
||||||
const input = screen.getByRole("textbox");
|
const input = screen.getByRole("textbox");
|
||||||
|
|
||||||
|
|||||||
@@ -435,6 +435,18 @@ describe("WysiwygComposer", () => {
|
|||||||
inputType: "insertText",
|
inputType: "insertText",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await waitFor(() => expect(onChange).toHaveBeenNthCalledWith(3, expect.stringContaining("😛")));
|
||||||
|
});
|
||||||
|
it("typing a space to trigger an emoji varitation replacement", async () => {
|
||||||
|
fireEvent.input(screen.getByRole("textbox"), {
|
||||||
|
data: ":-P",
|
||||||
|
inputType: "insertText",
|
||||||
|
});
|
||||||
|
fireEvent.input(screen.getByRole("textbox"), {
|
||||||
|
data: " ",
|
||||||
|
inputType: "insertText",
|
||||||
|
});
|
||||||
|
|
||||||
await waitFor(() => expect(onChange).toHaveBeenNthCalledWith(3, expect.stringContaining("😛")));
|
await waitFor(() => expect(onChange).toHaveBeenNthCalledWith(3, expect.stringContaining("😛")));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ describe("AutoRageshakeStore", () => {
|
|||||||
|
|
||||||
// @ts-ignore bypass private ctor for tests
|
// @ts-ignore bypass private ctor for tests
|
||||||
autoRageshakeStore = new AutoRageshakeStore();
|
autoRageshakeStore = new AutoRageshakeStore();
|
||||||
autoRageshakeStore.useUnitTestClient(client);
|
autoRageshakeStore.start();
|
||||||
|
|
||||||
utdEvent = mkEvent({
|
utdEvent = mkEvent({
|
||||||
event: true,
|
event: true,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ describe("OwnProfileStore", () => {
|
|||||||
displayname: "Display Name",
|
displayname: "Display Name",
|
||||||
avatar_url: "mxc://example.com/abc123",
|
avatar_url: "mxc://example.com/abc123",
|
||||||
});
|
});
|
||||||
await ownProfileStore.useUnitTestClient(client);
|
await ownProfileStore.start();
|
||||||
|
|
||||||
expect(onUpdate).toHaveBeenCalled();
|
expect(onUpdate).toHaveBeenCalled();
|
||||||
expect(ownProfileStore.displayName).toBe("Display Name");
|
expect(ownProfileStore.displayName).toBe("Display Name");
|
||||||
@@ -54,7 +54,7 @@ describe("OwnProfileStore", () => {
|
|||||||
errcode: "M_NOT_FOUND",
|
errcode: "M_NOT_FOUND",
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
await ownProfileStore.useUnitTestClient(client);
|
await ownProfileStore.start();
|
||||||
|
|
||||||
expect(onUpdate).toHaveBeenCalled();
|
expect(onUpdate).toHaveBeenCalled();
|
||||||
expect(ownProfileStore.displayName).toBe(client.getSafeUserId());
|
expect(ownProfileStore.displayName).toBe(client.getSafeUserId());
|
||||||
@@ -69,7 +69,7 @@ describe("OwnProfileStore", () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
await ownProfileStore.useUnitTestClient(client);
|
await ownProfileStore.start();
|
||||||
} catch (ignore) {}
|
} catch (ignore) {}
|
||||||
|
|
||||||
expect(onUpdate).not.toHaveBeenCalled();
|
expect(onUpdate).not.toHaveBeenCalled();
|
||||||
|
|||||||
@@ -1428,7 +1428,7 @@ describe("SpaceStore", () => {
|
|||||||
|
|
||||||
it("passes that value in calls to getVisibleRooms during getSpaceFilteredRoomIds", () => {
|
it("passes that value in calls to getVisibleRooms during getSpaceFilteredRoomIds", () => {
|
||||||
// Given a store
|
// Given a store
|
||||||
const store = SpaceStore.testInstance(client);
|
const store = SpaceStore.testInstance();
|
||||||
|
|
||||||
// When we ask for filtered room ids
|
// When we ask for filtered room ids
|
||||||
store.getSpaceFilteredRoomIds(MetaSpace.Home);
|
store.getSpaceFilteredRoomIds(MetaSpace.Home);
|
||||||
@@ -1478,7 +1478,7 @@ describe("SpaceStore", () => {
|
|||||||
|
|
||||||
it("passes that value in calls to getVisibleRooms during getSpaceFilteredRoomIds", () => {
|
it("passes that value in calls to getVisibleRooms during getSpaceFilteredRoomIds", () => {
|
||||||
// Given a store
|
// Given a store
|
||||||
const store = SpaceStore.testInstance(client);
|
const store = SpaceStore.testInstance();
|
||||||
// When we ask for filtered room ids
|
// When we ask for filtered room ids
|
||||||
store.getSpaceFilteredRoomIds(MetaSpace.Home);
|
store.getSpaceFilteredRoomIds(MetaSpace.Home);
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ describe("VoiceRecordingStore", () => {
|
|||||||
|
|
||||||
const mkStore = (): VoiceRecordingStore => {
|
const mkStore = (): VoiceRecordingStore => {
|
||||||
const store = new VoiceRecordingStore();
|
const store = new VoiceRecordingStore();
|
||||||
store.useUnitTestClient(stubClient);
|
store.start();
|
||||||
return store;
|
return store;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ describe("WidgetLayoutStore", () => {
|
|||||||
|
|
||||||
it("should recalculate all rooms when the client is ready", async () => {
|
it("should recalculate all rooms when the client is ready", async () => {
|
||||||
mocked(client.getVisibleRooms).mockReturnValue([mockRoom]);
|
mocked(client.getVisibleRooms).mockReturnValue([mockRoom]);
|
||||||
await store.start(client);
|
await store.start();
|
||||||
|
|
||||||
expect(roomUpdateListener).toHaveBeenCalled();
|
expect(roomUpdateListener).toHaveBeenCalled();
|
||||||
expect(store.getContainerWidgets(mockRoom, Container.Top)).toEqual([]);
|
expect(store.getContainerWidgets(mockRoom, Container.Top)).toEqual([]);
|
||||||
@@ -243,7 +243,7 @@ describe("WidgetLayoutStore", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should copy the layout to the room", async () => {
|
it("should copy the layout to the room", async () => {
|
||||||
await store.start(client);
|
await store.start();
|
||||||
store.recalculateRoom(mockRoom);
|
store.recalculateRoom(mockRoom);
|
||||||
store.moveToContainer(mockRoom, mockApps[0], Container.Top);
|
store.moveToContainer(mockRoom, mockApps[0], Container.Top);
|
||||||
store.copyLayoutToRoom(mockRoom);
|
store.copyLayoutToRoom(mockRoom);
|
||||||
@@ -297,7 +297,7 @@ describe("WidgetLayoutStore", () => {
|
|||||||
mocked(client.getVisibleRooms).mockReturnValue([]);
|
mocked(client.getVisibleRooms).mockReturnValue([]);
|
||||||
// @ts-ignore bypass private ctor for tests
|
// @ts-ignore bypass private ctor for tests
|
||||||
const store = new WidgetLayoutStore();
|
const store = new WidgetLayoutStore();
|
||||||
await store.start(client);
|
await store.start();
|
||||||
expect(client.getVisibleRooms).toHaveBeenCalledWith(false);
|
expect(client.getVisibleRooms).toHaveBeenCalledWith(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -314,7 +314,7 @@ describe("WidgetLayoutStore", () => {
|
|||||||
mocked(client.getVisibleRooms).mockReturnValue([]);
|
mocked(client.getVisibleRooms).mockReturnValue([]);
|
||||||
// @ts-ignore bypass private ctor for tests
|
// @ts-ignore bypass private ctor for tests
|
||||||
const store = new WidgetLayoutStore();
|
const store = new WidgetLayoutStore();
|
||||||
await store.start(client);
|
await store.start();
|
||||||
expect(client.getVisibleRooms).toHaveBeenCalledWith(true);
|
expect(client.getVisibleRooms).toHaveBeenCalledWith(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ describe("MessagePreviewStore", () => {
|
|||||||
mocked(client.getRoom).mockReturnValue(room);
|
mocked(client.getRoom).mockReturnValue(room);
|
||||||
|
|
||||||
store = MessagePreviewStore.testInstance();
|
store = MessagePreviewStore.testInstance();
|
||||||
await store.useUnitTestClient(client);
|
await store.start();
|
||||||
await setupAsyncStoreWithClient(store, client);
|
await setupAsyncStoreWithClient(store, client);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,6 @@ import DMRoomMap from "../../../src/utils/DMRoomMap";
|
|||||||
import { flushPromises, stubClient, upsertRoomStateEvents, mkRoom } from "../../test-utils";
|
import { flushPromises, stubClient, upsertRoomStateEvents, mkRoom } from "../../test-utils";
|
||||||
import { DEFAULT_PUSH_RULES, makePushRule } from "../../test-utils/pushRules";
|
import { DEFAULT_PUSH_RULES, makePushRule } from "../../test-utils/pushRules";
|
||||||
|
|
||||||
// Mock out the SpaceWatcher as it messes with the prefilterConditions
|
|
||||||
jest.mock("../../../src/stores/room-list/SpaceWatcher.ts");
|
|
||||||
|
|
||||||
describe("RoomListStore", () => {
|
describe("RoomListStore", () => {
|
||||||
const client = stubClient();
|
const client = stubClient();
|
||||||
const newRoomId = "!roomid:example.com";
|
const newRoomId = "!roomid:example.com";
|
||||||
@@ -94,10 +91,6 @@ describe("RoomListStore", () => {
|
|||||||
await (RoomListStore.instance as RoomListStoreClass).makeReady(client);
|
await (RoomListStore.instance as RoomListStoreClass).makeReady(client);
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
DMRoomMap.makeShared(client);
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each(OrderedDefaultTagIDs)("defaults to importance ordering for %s=", (tagId) => {
|
it.each(OrderedDefaultTagIDs)("defaults to importance ordering for %s=", (tagId) => {
|
||||||
expect(RoomListStore.instance.getTagSorting(tagId)).toBe(SortAlgorithm.Recent);
|
expect(RoomListStore.instance.getTagSorting(tagId)).toBe(SortAlgorithm.Recent);
|
||||||
});
|
});
|
||||||
@@ -109,11 +102,11 @@ describe("RoomListStore", () => {
|
|||||||
function createStore(): { store: RoomListStoreClass; handleRoomUpdate: jest.Mock<any, any> } {
|
function createStore(): { store: RoomListStoreClass; handleRoomUpdate: jest.Mock<any, any> } {
|
||||||
const fakeDispatcher = { register: jest.fn() } as unknown as MatrixDispatcher;
|
const fakeDispatcher = { register: jest.fn() } as unknown as MatrixDispatcher;
|
||||||
const store = new RoomListStoreClass(fakeDispatcher);
|
const store = new RoomListStoreClass(fakeDispatcher);
|
||||||
|
// @ts-ignore accessing private member to set client
|
||||||
|
store.readyStore.matrixClient = client;
|
||||||
const handleRoomUpdate = jest.fn();
|
const handleRoomUpdate = jest.fn();
|
||||||
// @ts-ignore accessing private member to mock it
|
// @ts-ignore accessing private member to mock it
|
||||||
store.algorithm.handleRoomUpdate = handleRoomUpdate;
|
store.algorithm.handleRoomUpdate = handleRoomUpdate;
|
||||||
// @ts-ignore accessing private member to set client
|
|
||||||
store.readyStore.useUnitTestClient(client);
|
|
||||||
|
|
||||||
return { store, handleRoomUpdate };
|
return { store, handleRoomUpdate };
|
||||||
}
|
}
|
||||||
@@ -164,6 +157,7 @@ describe("RoomListStore", () => {
|
|||||||
room1.updateMyMembership(KnownMembership.Join);
|
room1.updateMyMembership(KnownMembership.Join);
|
||||||
room2.updateMyMembership(KnownMembership.Join);
|
room2.updateMyMembership(KnownMembership.Join);
|
||||||
room3.updateMyMembership(KnownMembership.Join);
|
room3.updateMyMembership(KnownMembership.Join);
|
||||||
|
DMRoomMap.makeShared(client);
|
||||||
const { store } = createStore();
|
const { store } = createStore();
|
||||||
client.getVisibleRooms = jest.fn().mockReturnValue([room1, room2, room3]);
|
client.getVisibleRooms = jest.fn().mockReturnValue([room1, room2, room3]);
|
||||||
|
|
||||||
@@ -275,6 +269,7 @@ describe("RoomListStore", () => {
|
|||||||
|
|
||||||
it("Passes the feature flag on to the client when asking for visible rooms", () => {
|
it("Passes the feature flag on to the client when asking for visible rooms", () => {
|
||||||
// Given a store that we can ask for a room list
|
// Given a store that we can ask for a room list
|
||||||
|
DMRoomMap.makeShared(client);
|
||||||
const { store } = createStore();
|
const { store } = createStore();
|
||||||
client.getVisibleRooms = jest.fn().mockReturnValue([]);
|
client.getVisibleRooms = jest.fn().mockReturnValue([]);
|
||||||
|
|
||||||
@@ -290,7 +285,7 @@ describe("RoomListStore", () => {
|
|||||||
describe("room updates", () => {
|
describe("room updates", () => {
|
||||||
const makeStore = async () => {
|
const makeStore = async () => {
|
||||||
const store = new RoomListStoreClass(defaultDispatcher);
|
const store = new RoomListStoreClass(defaultDispatcher);
|
||||||
await store.useUnitTestClient(client);
|
await store.start();
|
||||||
return store;
|
return store;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ describe("SlidingRoomListStore", () => {
|
|||||||
|
|
||||||
describe("spaces", () => {
|
describe("spaces", () => {
|
||||||
it("alters 'filters.spaces' on the DefaultTagID.Untagged list when the selected space changes", async () => {
|
it("alters 'filters.spaces' on the DefaultTagID.Untagged list when the selected space changes", async () => {
|
||||||
await store.useUnitTestClient(context.client!); // call onReady
|
await store.start(); // call onReady
|
||||||
const spaceRoomId = "!foo:bar";
|
const spaceRoomId = "!foo:bar";
|
||||||
|
|
||||||
const p = untilEmission(store, LISTS_LOADING_EVENT, (listName, isLoading) => {
|
const p = untilEmission(store, LISTS_LOADING_EVENT, (listName, isLoading) => {
|
||||||
@@ -92,7 +92,7 @@ describe("SlidingRoomListStore", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
activeSpace = MetaSpace.Home;
|
activeSpace = MetaSpace.Home;
|
||||||
await store.useUnitTestClient(context.client!); // call onReady
|
await store.start(); // call onReady
|
||||||
|
|
||||||
expect(context._SlidingSyncManager!.ensureListRegistered).toHaveBeenCalledWith(DefaultTagID.Untagged, {
|
expect(context._SlidingSyncManager!.ensureListRegistered).toHaveBeenCalledWith(DefaultTagID.Untagged, {
|
||||||
filters: expect.objectContaining({
|
filters: expect.objectContaining({
|
||||||
@@ -108,7 +108,7 @@ describe("SlidingRoomListStore", () => {
|
|||||||
const p = untilEmission(store, LISTS_LOADING_EVENT, (listName, isLoading) => {
|
const p = untilEmission(store, LISTS_LOADING_EVENT, (listName, isLoading) => {
|
||||||
return listName === DefaultTagID.Untagged && !isLoading;
|
return listName === DefaultTagID.Untagged && !isLoading;
|
||||||
});
|
});
|
||||||
await store.useUnitTestClient(context.client!); // call onReady
|
await store.start(); // call onReady
|
||||||
await p;
|
await p;
|
||||||
expect(context._SlidingSyncManager!.ensureListRegistered).toHaveBeenCalledWith(
|
expect(context._SlidingSyncManager!.ensureListRegistered).toHaveBeenCalledWith(
|
||||||
DefaultTagID.Untagged,
|
DefaultTagID.Untagged,
|
||||||
@@ -121,7 +121,7 @@ describe("SlidingRoomListStore", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("includes subspaces in 'filters.spaces' when the selected space has subspaces", async () => {
|
it("includes subspaces in 'filters.spaces' when the selected space has subspaces", async () => {
|
||||||
await store.useUnitTestClient(context.client!); // call onReady
|
await store.start(); // call onReady
|
||||||
const spaceRoomId = "!foo:bar";
|
const spaceRoomId = "!foo:bar";
|
||||||
const subSpace1 = "!ss1:bar";
|
const subSpace1 = "!ss1:bar";
|
||||||
const subSpace2 = "!ss2:bar";
|
const subSpace2 = "!ss2:bar";
|
||||||
@@ -168,7 +168,7 @@ describe("SlidingRoomListStore", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("getTagsForRoom gets the tags for the room", async () => {
|
it("getTagsForRoom gets the tags for the room", async () => {
|
||||||
await store.useUnitTestClient(context.client!);
|
await store.start();
|
||||||
const roomA = "!a:localhost";
|
const roomA = "!a:localhost";
|
||||||
const roomB = "!b:localhost";
|
const roomB = "!b:localhost";
|
||||||
const keyToListData: Record<string, { joinedCount: number; roomIndexToRoomId: Record<number, string> }> = {
|
const keyToListData: Record<string, { joinedCount: number; roomIndexToRoomId: Record<number, string> }> = {
|
||||||
@@ -200,7 +200,7 @@ describe("SlidingRoomListStore", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("emits LISTS_UPDATE_EVENT when slidingSync lists update", async () => {
|
it("emits LISTS_UPDATE_EVENT when slidingSync lists update", async () => {
|
||||||
await store.useUnitTestClient(context.client!);
|
await store.start();
|
||||||
const roomA = "!a:localhost";
|
const roomA = "!a:localhost";
|
||||||
const roomB = "!b:localhost";
|
const roomB = "!b:localhost";
|
||||||
const roomC = "!c:localhost";
|
const roomC = "!c:localhost";
|
||||||
@@ -236,7 +236,7 @@ describe("SlidingRoomListStore", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("sets the sticky room on the basis of the viewed room in RoomViewStore", async () => {
|
it("sets the sticky room on the basis of the viewed room in RoomViewStore", async () => {
|
||||||
await store.useUnitTestClient(context.client!);
|
await store.start();
|
||||||
// seed the store with 3 rooms
|
// seed the store with 3 rooms
|
||||||
const roomIdA = "!a:localhost";
|
const roomIdA = "!a:localhost";
|
||||||
const roomIdB = "!b:localhost";
|
const roomIdB = "!b:localhost";
|
||||||
@@ -301,7 +301,7 @@ describe("SlidingRoomListStore", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("gracefully handles unknown room IDs", async () => {
|
it("gracefully handles unknown room IDs", async () => {
|
||||||
await store.useUnitTestClient(context.client!);
|
await store.start();
|
||||||
const roomIdA = "!a:localhost";
|
const roomIdA = "!a:localhost";
|
||||||
const roomIdB = "!b:localhost"; // does not exist
|
const roomIdB = "!b:localhost"; // does not exist
|
||||||
const roomIdC = "!c:localhost";
|
const roomIdC = "!c:localhost";
|
||||||
|
|||||||
@@ -1898,13 +1898,13 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@matrix-org/analytics-events/-/analytics-events-0.26.0.tgz#7c8f8f924d8313c87951a0e941640ef8ff78f3d6"
|
resolved "https://registry.yarnpkg.com/@matrix-org/analytics-events/-/analytics-events-0.26.0.tgz#7c8f8f924d8313c87951a0e941640ef8ff78f3d6"
|
||||||
integrity sha512-cjKZBejajUG8wPhVygMkBTwTLdEn74luUP6g6RjCUqPR3RYIl3NVi58Zil8CWfRTILb4wVLCPpAvehgXJn1HnQ==
|
integrity sha512-cjKZBejajUG8wPhVygMkBTwTLdEn74luUP6g6RjCUqPR3RYIl3NVi58Zil8CWfRTILb4wVLCPpAvehgXJn1HnQ==
|
||||||
|
|
||||||
"@matrix-org/emojibase-bindings@^1.1.2":
|
"@matrix-org/emojibase-bindings@^1.3.3":
|
||||||
version "1.1.3"
|
version "1.3.3"
|
||||||
resolved "https://registry.yarnpkg.com/@matrix-org/emojibase-bindings/-/emojibase-bindings-1.1.3.tgz#d35f0367d586d83261564662b6bb67fda8845d68"
|
resolved "https://registry.yarnpkg.com/@matrix-org/emojibase-bindings/-/emojibase-bindings-1.3.3.tgz#cee82a739c0866bf3100b03755647ace1f3ba6ef"
|
||||||
integrity sha512-ljr0kPerx8yUc4JVJz7japebb1ZbtGH4V4cvlO2LYgTg+warjagDwkJ5x+ZUVuTU6MH8x0LrUxmkqVgmSoQyWA==
|
integrity sha512-GwuZdmF+wZT34RKehQYjTzdgba1ju2W3FM4jPJfwqh0jUxVXZLb+6b6dV3lna6/7EDzgGvOMwTwCAolILDwS0g==
|
||||||
dependencies:
|
dependencies:
|
||||||
emojibase "^15.0.0"
|
emojibase "^15.3.1"
|
||||||
emojibase-data "^15.0.0"
|
emojibase-data "^15.3.1"
|
||||||
|
|
||||||
"@matrix-org/matrix-sdk-crypto-wasm@^7.0.0":
|
"@matrix-org/matrix-sdk-crypto-wasm@^7.0.0":
|
||||||
version "7.0.0"
|
version "7.0.0"
|
||||||
@@ -4431,20 +4431,20 @@ emoji-regex@^9.2.2:
|
|||||||
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72"
|
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72"
|
||||||
integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==
|
integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==
|
||||||
|
|
||||||
emojibase-data@^15.0.0:
|
emojibase-data@^15.3.1:
|
||||||
version "15.2.0"
|
version "15.3.2"
|
||||||
resolved "https://registry.yarnpkg.com/emojibase-data/-/emojibase-data-15.2.0.tgz#475a786c091a101ef4bcf57227771c6260ee39b2"
|
resolved "https://registry.yarnpkg.com/emojibase-data/-/emojibase-data-15.3.2.tgz#2742246bfe14f16a7829b42ca156dec09934cf85"
|
||||||
integrity sha512-hDiw4ugxnI4pcVQO+73NlKx6aZP/A+BAPfDgK/3A83RVbHZa0Ut6GHpd5r5XUV9G7BZhKejlIRuxhXialpbt6Q==
|
integrity sha512-TpDyTDDTdqWIJixV5sTA6OQ0P0JfIIeK2tFRR3q56G9LK65ylAZ7z3KyBXokpvTTJ+mLUXQXbLNyVkjvnTLE+A==
|
||||||
|
|
||||||
emojibase-regex@15.3.2:
|
emojibase-regex@15.3.2:
|
||||||
version "15.3.2"
|
version "15.3.2"
|
||||||
resolved "https://registry.yarnpkg.com/emojibase-regex/-/emojibase-regex-15.3.2.tgz#5175231715b86d4b437754527288844a6c29318f"
|
resolved "https://registry.yarnpkg.com/emojibase-regex/-/emojibase-regex-15.3.2.tgz#5175231715b86d4b437754527288844a6c29318f"
|
||||||
integrity sha512-ue6BVeb2qu33l97MkxcOoyMJlg6Tug3eTv2z1at+M9TjvlWKvdmAPvZIDG1JbT2RH3FSyJNLucO5K5H/yxT03w==
|
integrity sha512-ue6BVeb2qu33l97MkxcOoyMJlg6Tug3eTv2z1at+M9TjvlWKvdmAPvZIDG1JbT2RH3FSyJNLucO5K5H/yxT03w==
|
||||||
|
|
||||||
emojibase@^15.0.0:
|
emojibase@^15.3.1:
|
||||||
version "15.2.0"
|
version "15.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/emojibase/-/emojibase-15.2.0.tgz#0a175d4218f4a1600f2ada6b3a3184cef1b3ec7b"
|
resolved "https://registry.yarnpkg.com/emojibase/-/emojibase-15.3.1.tgz#7f6ff5482486f23e59a457de64e974bd35f3c9a3"
|
||||||
integrity sha512-gB6rIVtyJPersQvAo4nOGYPeILMhlcfZdiwCWVeRAtkJ7sm0tExZETGyLhrTQcHvZQhDEYI1vlCeqUhn5gZkQA==
|
integrity sha512-GNsjHnG2J3Ktg684Fs/vZR/6XpOSkZPMAv85EHrr6br2RN2cJNwdS4am/3YSK3y+/gOv2kmoK3GGdahXdMxg2g==
|
||||||
|
|
||||||
emojis-list@^3.0.0:
|
emojis-list@^3.0.0:
|
||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user