From ad60365403d46b208e7bdd6f0ca8b4c79316411a Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Tue, 8 Oct 2024 10:51:50 +0200 Subject: [PATCH 1/6] Remove `VerificationExplorer` --- .../views/dialogs/DevtoolsDialog.tsx | 2 - .../dialogs/devtools/VerificationExplorer.tsx | 98 ------------------- src/i18n/strings/en_EN.json | 13 --- .../DevtoolsDialog-test.tsx.snap | 5 - 4 files changed, 118 deletions(-) diff --git a/src/components/views/dialogs/DevtoolsDialog.tsx b/src/components/views/dialogs/DevtoolsDialog.tsx index f06c5af1987..7319685014c 100644 --- a/src/components/views/dialogs/DevtoolsDialog.tsx +++ b/src/components/views/dialogs/DevtoolsDialog.tsx @@ -14,7 +14,6 @@ import MatrixClientContext from "../../../contexts/MatrixClientContext"; import BaseDialog from "./BaseDialog"; import { TimelineEventEditor } from "./devtools/Event"; import ServersInRoom from "./devtools/ServersInRoom"; -import VerificationExplorer from "./devtools/VerificationExplorer"; import SettingExplorer from "./devtools/SettingExplorer"; import { RoomStateExplorer } from "./devtools/RoomState"; import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./devtools/BaseTool"; @@ -45,7 +44,6 @@ const Tools: Record = { [_td("devtools|explore_room_account_data"), RoomAccountDataExplorer], [_td("devtools|view_servers_in_room"), ServersInRoom], [_td("devtools|notifications_debug"), RoomNotifications], - [_td("devtools|verification_explorer"), VerificationExplorer], [_td("devtools|active_widgets"), WidgetExplorer], ], [Category.Other]: [ diff --git a/src/components/views/dialogs/devtools/VerificationExplorer.tsx b/src/components/views/dialogs/devtools/VerificationExplorer.tsx index 017f1b95b47..e69de29bb2d 100644 --- a/src/components/views/dialogs/devtools/VerificationExplorer.tsx +++ b/src/components/views/dialogs/devtools/VerificationExplorer.tsx @@ -1,98 +0,0 @@ -/* -Copyright 2024 New Vector Ltd. -Copyright 2023 The Matrix.org Foundation C.I.C. -Copyright 2022 Michael Telatynski <7t3chguy@gmail.com> - -SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only -Please see LICENSE files in the repository root for full details. -*/ - -import React, { useContext, useEffect, useState } from "react"; -import { - VerificationPhase as Phase, - VerificationRequest, - VerificationRequestEvent, - CryptoEvent, -} from "matrix-js-sdk/src/crypto-api"; - -import { useTypedEventEmitter, useTypedEventEmitterState } from "../../../../hooks/useEventEmitter"; -import { _t, _td, TranslationKey } from "../../../../languageHandler"; -import MatrixClientContext from "../../../../contexts/MatrixClientContext"; -import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./BaseTool"; -import { Tool } from "../DevtoolsDialog"; - -const PHASE_MAP: Record = { - [Phase.Unsent]: _td("common|unsent"), - [Phase.Requested]: _td("devtools|phase_requested"), - [Phase.Ready]: _td("devtools|phase_ready"), - [Phase.Done]: _td("action|done"), - [Phase.Started]: _td("devtools|phase_started"), - [Phase.Cancelled]: _td("devtools|phase_cancelled"), -}; - -const VerificationRequestExplorer: React.FC<{ - txnId: string; - request: VerificationRequest; -}> = ({ txnId, request }) => { - const [, updateState] = useState(); - const [timeout, setRequestTimeout] = useState(request.timeout); - - /* Re-render if something changes state */ - useTypedEventEmitter(request, VerificationRequestEvent.Change, updateState); - - /* Keep re-rendering if there's a timeout */ - useEffect(() => { - if (request.timeout == 0) return; - - /* Note that request.timeout is a getter, so its value changes */ - const id = window.setInterval(() => { - setRequestTimeout(request.timeout); - }, 500); - - return () => { - clearInterval(id); - }; - }, [request]); - - return ( -
-
-
{_t("devtools|phase_transaction")}
-
{txnId}
-
{_t("devtools|phase")}
-
{PHASE_MAP[request.phase] ? _t(PHASE_MAP[request.phase]) : request.phase}
-
{_t("devtools|timeout")}
-
{timeout === null ? _t("devtools|timeout_none") : Math.floor(timeout / 1000)}
-
{_t("devtools|methods")}
-
{request.methods && request.methods.join(", ")}
-
{_t("devtools|other_user")}
-
{request.otherUserId}
-
-
- ); -}; - -const VerificationExplorer: Tool = ({ onBack }: IDevtoolsProps) => { - const cli = useContext(MatrixClientContext); - const context = useContext(DevtoolsContext); - - const requests = useTypedEventEmitterState(cli, CryptoEvent.VerificationRequestReceived, () => { - return ( - cli.crypto?.inRoomVerificationRequests["requestsByRoomId"]?.get(context.room.roomId) ?? - new Map() - ); - }); - - return ( - - {Array.from(requests.entries()) - .reverse() - .map(([txnId, request]) => ( - - ))} - {requests.size < 1 && _t("devtools|no_verification_requests_found")} - - ); -}; - -export default VerificationExplorer; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 35dfab239df..5d346a66537 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -579,7 +579,6 @@ "unmute": "Unmute", "unnamed_room": "Unnamed Room", "unnamed_space": "Unnamed Space", - "unsent": "Unsent", "unverified": "Unverified", "updating": "Updating...", "user": "User", @@ -764,20 +763,11 @@ "low_bandwidth_mode": "Low bandwidth mode", "low_bandwidth_mode_description": "Requires compatible homeserver.", "main_timeline": "Main timeline", - "methods": "Methods", "no_receipt_found": "No receipt found", - "no_verification_requests_found": "No verification requests found", "notification_state": "Notification state is %(notificationState)s", "notifications_debug": "Notifications debug", "number_of_users": "Number of users", "original_event_source": "Original event source", - "other_user": "Other user", - "phase": "Phase", - "phase_cancelled": "Cancelled", - "phase_ready": "Ready", - "phase_requested": "Requested", - "phase_started": "Started", - "phase_transaction": "Transaction", "room_encrypted": "Room is encrypted ✅", "room_id": "Room ID: %(roomId)s", "room_not_encrypted": "Room is not encrypted 🚨", @@ -815,8 +805,6 @@ "state_key": "State Key", "thread_root_id": "Thread Root ID: %(threadRootId)s", "threads_timeline": "Threads timeline", - "timeout": "Timeout", - "timeout_none": "None", "title": "Developer tools", "toggle_event": "toggle event", "toolbox": "Toolbox", @@ -833,7 +821,6 @@ "values_explicit_colon": "Values at explicit levels:", "values_explicit_room": "Values at explicit levels in this room", "values_explicit_this_room_colon": "Values at explicit levels in this room:", - "verification_explorer": "Verification explorer", "view_servers_in_room": "View servers in room", "view_source_decrypted_event_source": "Decrypted event source", "view_source_decrypted_event_source_unavailable": "Decrypted source unavailable", diff --git a/test/unit-tests/components/views/dialogs/__snapshots__/DevtoolsDialog-test.tsx.snap b/test/unit-tests/components/views/dialogs/__snapshots__/DevtoolsDialog-test.tsx.snap index fca0dc9885d..6cd547e58bf 100644 --- a/test/unit-tests/components/views/dialogs/__snapshots__/DevtoolsDialog-test.tsx.snap +++ b/test/unit-tests/components/views/dialogs/__snapshots__/DevtoolsDialog-test.tsx.snap @@ -75,11 +75,6 @@ exports[`DevtoolsDialog renders the devtools dialog 1`] = ` > Notifications debug -