* Add joining with knock room creation flow. Also add `WaitForInviteView` after knocking. And appropriate error views when knock failed or gets rejected. Signed-off-by: Timo K <toger5@hotmail.de> * Refactor encryption information. We had lots of enums and booleans to describe the encryption situation. Now we only use the `EncryptionSystem` "enum" which contains the additional information like sharedKey. (and we don't use the isRoomE2EE function that is somewhat confusing since it checks `return widget === null && !room.getCanonicalAlias();` which is only indirectly related to e2ee) Signed-off-by: Timo K <toger5@hotmail.de> * Update recent list. - Don't use deprecated `groupCallEventHander` anymore (it used the old `m.call` state event.) - make the recent list reactive (getting removed from a call removes the item from the list) - support having rooms without shared secret but actual matrix encryption in the recent list - change the share link creation button so that we create a link with pwd for sharedKey rooms and with `perParticipantE2EE=true` for matrix encrypted rooms. Signed-off-by: Timo K <toger5@hotmail.de> * fix types Signed-off-by: Timo K <toger5@hotmail.de> * patch js-sdk for linter Signed-off-by: Timo K <toger5@hotmail.de> * ignore ts expect error Signed-off-by: Timo K <toger5@hotmail.de> * Fix error in widget mode. We cannot call client.getRoomSummary in widget mode. The code path needs to throw before reaching this call. (In general we should never call getRoomSummary if getRoom returns a room) Signed-off-by: Timo K <toger5@hotmail.de> * tempDemo Signed-off-by: Timo K <toger5@hotmail.de> * remove wait for invite view Signed-off-by: Timo K <toger5@hotmail.de> * yarn i18n Signed-off-by: Timo K <toger5@hotmail.de> * reset back mute participant count * add logic to show error view when getting removed * include reason whenever someone gets removed from a call. * fix activeRoom not beeing early enough * fix lints * add comment about encryption situation Signed-off-by: Timo K <toger5@hotmail.de> * Fix lockfile * Use (unmerged!) RoomSummary type from the js-sdk Temporarily change the js-sdk dependency to the PR branch that provides that type * review Signed-off-by: Timo K <toger5@hotmail.de> * review (remove participant count unknown) Signed-off-by: Timo K <toger5@hotmail.de> * remove error for unencrypted calls (allow intentional unencrypted calls) Signed-off-by: Timo K <toger5@hotmail.de> * update js-sdk Signed-off-by: Timo K <toger5@hotmail.de> --------- Signed-off-by: Timo K <toger5@hotmail.de> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
96 lines
3.2 KiB
TypeScript
96 lines
3.2 KiB
TypeScript
/*
|
|
Copyright 2023 New Vector Ltd
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
import { FC, MouseEvent, useCallback, useMemo, useState } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { Button, Text } from "@vector-im/compound-web";
|
|
import PopOutIcon from "@vector-im/compound-design-tokens/icons/pop-out.svg?react";
|
|
import { logger } from "matrix-js-sdk/src/logger";
|
|
|
|
import { Modal } from "../Modal";
|
|
import { useRoomEncryptionSystem } from "../e2ee/sharedKeyManagement";
|
|
import { getAbsoluteRoomUrl } from "../matrix-utils";
|
|
import styles from "./AppSelectionModal.module.css";
|
|
import { editFragmentQuery } from "../UrlParams";
|
|
import { E2eeType } from "../e2ee/e2eeType";
|
|
|
|
interface Props {
|
|
roomId: string;
|
|
}
|
|
|
|
export const AppSelectionModal: FC<Props> = ({ roomId }) => {
|
|
const { t } = useTranslation();
|
|
|
|
const [open, setOpen] = useState(true);
|
|
const onBrowserClick = useCallback(
|
|
(e: MouseEvent) => {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
setOpen(false);
|
|
},
|
|
[setOpen],
|
|
);
|
|
const e2eeSystem = useRoomEncryptionSystem(roomId);
|
|
|
|
if (e2eeSystem.kind === E2eeType.NONE) {
|
|
logger.error(
|
|
"Generating app redirect URL for encrypted room but don't have key available!",
|
|
);
|
|
}
|
|
|
|
const appUrl = useMemo(() => {
|
|
// If the room ID is not known, fall back to the URL of the current page
|
|
// Also, we don't really know the room name at this stage as we haven't
|
|
// started a client and synced to get the room details. We could take the one
|
|
// we got in our own URL and use that, but it's not a string that a human
|
|
// ever sees so it's somewhat redundant. We just don't pass a name.
|
|
const url = new URL(
|
|
roomId === null
|
|
? window.location.href
|
|
: getAbsoluteRoomUrl(roomId, e2eeSystem),
|
|
);
|
|
// Edit the URL to prevent the app selection prompt from appearing a second
|
|
// time within the app, and to keep the user confined to the current room
|
|
url.hash = editFragmentQuery(url.hash, (params) => {
|
|
params.set("appPrompt", "false");
|
|
params.set("confineToRoom", "true");
|
|
return params;
|
|
});
|
|
|
|
const result = new URL("io.element.call:/");
|
|
result.searchParams.set("url", url.toString());
|
|
return result.toString();
|
|
}, [e2eeSystem, roomId]);
|
|
|
|
return (
|
|
<Modal
|
|
className={styles.modal}
|
|
title={t("app_selection_modal.title")}
|
|
open={open}
|
|
>
|
|
<Text size="md" weight="semibold">
|
|
{t("app_selection_modal.text")}
|
|
</Text>
|
|
<Button kind="secondary" onClick={onBrowserClick}>
|
|
{t("app_selection_modal.continue_in_browser")}
|
|
</Button>
|
|
<Button as="a" href={appUrl} Icon={PopOutIcon}>
|
|
{t("app_selection_modal.open_in_app")}
|
|
</Button>
|
|
</Modal>
|
|
);
|
|
};
|