From 4348edf6d02f1c947710befac802f644a560680f Mon Sep 17 00:00:00 2001 From: Timo K Date: Mon, 30 Oct 2023 15:24:21 +0100 Subject: [PATCH 1/4] add f-twelve web console Signed-off-by: Timo K --- package.json | 1 + src/App.tsx | 2 ++ src/f-twelve.d.ts | 23 +++++++++++++++++++++++ src/settings/SettingsModal.tsx | 29 +++++++++++++++++++++++++++-- src/settings/useSetting.ts | 2 ++ yarn.lock | 12 ++++++++++++ 6 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 src/f-twelve.d.ts diff --git a/package.json b/package.json index aa75ab2a5..da78ab2b0 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "buffer": "^6.0.3", "classnames": "^2.3.1", "events": "^3.3.0", + "f-twelve": "^2.3.4", "i18next": "^23.0.0", "i18next-browser-languagedetector": "^7.0.0", "i18next-http-backend": "^2.0.0", diff --git a/src/App.tsx b/src/App.tsx index bcd049b12..c1947c549 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -25,6 +25,7 @@ import * as Sentry from "@sentry/react"; import { OverlayProvider } from "@react-aria/overlays"; import { History } from "history"; import { TooltipProvider } from "@vector-im/compound-web"; +import WebConsole from "f-twelve"; import { HomePage } from "./home/HomePage"; import { LoginPage } from "./auth/LoginPage"; @@ -39,6 +40,7 @@ import { widget } from "./widget"; import { useTheme } from "./useTheme"; const SentryRoute = Sentry.withSentryRouting(Route); +WebConsole.enable({ show: false }); interface SimpleProviderProps { children: JSX.Element; diff --git a/src/f-twelve.d.ts b/src/f-twelve.d.ts new file mode 100644 index 000000000..abd2ba71d --- /dev/null +++ b/src/f-twelve.d.ts @@ -0,0 +1,23 @@ +/* +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. +*/ +declare module "f-twelve" { + interface EnableOpts { + show: boolean; + } + export function enable(opts: EnableOpts): void; + export function show(): void; + export function hide(): void; +} diff --git a/src/settings/SettingsModal.tsx b/src/settings/SettingsModal.tsx index a86f20c53..bc68a55c9 100644 --- a/src/settings/SettingsModal.tsx +++ b/src/settings/SettingsModal.tsx @@ -13,8 +13,8 @@ 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 { ChangeEvent, FC, Key, ReactNode } from "react"; +import WebConsole from "f-twelve"; +import { ChangeEvent, FC, Key, ReactNode, useEffect } from "react"; import { Item } from "@react-stately/collections"; import { Trans, useTranslation } from "react-i18next"; import { MatrixClient } from "matrix-js-sdk"; @@ -34,6 +34,7 @@ import { useDeveloperSettingsTab, useShowConnectionStats, isFirefox, + useShowInlineWebConsole, } from "./useSetting"; import { FieldRow, InputField } from "../input/Input"; import { Body, Caption } from "../typography/Typography"; @@ -228,6 +229,15 @@ export const SettingsModal: FC = ({ ); + const [webConsoleShown, setWebConsoleShown] = useShowInlineWebConsole(); + useEffect(() => { + if (webConsoleShown) { + WebConsole.show(); + } else { + WebConsole.hide(); + } + }); + const developerTab = ( = ({ } /> + + ): void => + setWebConsoleShown(e.target.checked) + } + /> + ); diff --git a/src/settings/useSetting.ts b/src/settings/useSetting.ts index a2733b98c..90f3b424f 100644 --- a/src/settings/useSetting.ts +++ b/src/settings/useSetting.ts @@ -102,3 +102,5 @@ export const useAudioOutput = (): Setting => useSetting("audio-output", undefined); export const useVideoInput = (): Setting => useSetting("video-input", undefined); +export const useShowInlineWebConsole = (): Setting => + useSetting("show-web-console", false); diff --git a/yarn.lock b/yarn.lock index 6ce850559..3aa8a61eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5058,6 +5058,13 @@ execa@^8.0.1: signal-exit "^4.1.0" strip-final-newline "^3.0.0" +f-twelve@^2.3.4: + version "2.3.4" + resolved "https://registry.yarnpkg.com/f-twelve/-/f-twelve-2.3.4.tgz#cfd67b3b1c0d458530b7329b8040b8714ef92685" + integrity sha512-G1W8qDICF8i4fo93jd1JZPJdpiyunFhExlKBGml6g+nPfOE5Tc+zUaMb74laqe9o/cfakn/OJhYA4mlwqZf4Gg== + dependencies: + preact "^10.5.3" + fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" @@ -7146,6 +7153,11 @@ preact@^10.19.3: resolved "https://registry.yarnpkg.com/preact/-/preact-10.20.1.tgz#1bc598ab630d8612978f7533da45809a8298542b" integrity sha512-JIFjgFg9B2qnOoGiYMVBtrcFxHqn+dNXbq76bVmcaHYJFYR4lW67AOcXgAYQQTDYXDOg/kTZrKPNCdRgJ2UJmw== +preact@^10.5.3: + version "10.18.1" + resolved "https://registry.yarnpkg.com/preact/-/preact-10.18.1.tgz#3b84bb305f0b05f4ad5784b981d15fcec4e105da" + integrity sha512-mKUD7RRkQQM6s7Rkmi7IFkoEHjuFqRQUaXamO61E6Nn7vqF/bo7EZCmSyrUnp2UWHw0O7XjZ2eeXis+m7tf4lg== + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" From 2878ea53aeb3f2a932fe1ff85e59dbcaa3f00a17 Mon Sep 17 00:00:00 2001 From: Timo Date: Thu, 23 May 2024 16:17:17 +0200 Subject: [PATCH 2/4] default show --- src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index c1947c549..91107ee1c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -40,7 +40,7 @@ import { widget } from "./widget"; import { useTheme } from "./useTheme"; const SentryRoute = Sentry.withSentryRouting(Route); -WebConsole.enable({ show: false }); +WebConsole.enable({ show: true }); interface SimpleProviderProps { children: JSX.Element; From 41e3e21d970602e20bf269f608813e4417fd645a Mon Sep 17 00:00:00 2001 From: Timo Date: Thu, 23 May 2024 16:19:03 +0200 Subject: [PATCH 3/4] make it also have the setting on (dont know if it otherwise immediately hides it again) --- src/settings/useSetting.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings/useSetting.ts b/src/settings/useSetting.ts index 90f3b424f..77459a72d 100644 --- a/src/settings/useSetting.ts +++ b/src/settings/useSetting.ts @@ -103,4 +103,4 @@ export const useAudioOutput = (): Setting => export const useVideoInput = (): Setting => useSetting("video-input", undefined); export const useShowInlineWebConsole = (): Setting => - useSetting("show-web-console", false); + useSetting("show-web-console", true); From daedd7db9d0fb403235b6e883078002c970bea41 Mon Sep 17 00:00:00 2001 From: Timo Date: Thu, 23 May 2024 16:54:53 +0200 Subject: [PATCH 4/4] remove group call permission --- src/widget.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/widget.ts b/src/widget.ts index ad7156e30..a066b57d4 100644 --- a/src/widget.ts +++ b/src/widget.ts @@ -123,7 +123,6 @@ export const widget = ((): WidgetHelpers | null => { const receiveState = [ { eventType: EventType.RoomMember }, { eventType: EventType.RoomEncryption }, - { eventType: EventType.GroupCallPrefix }, { eventType: EventType.GroupCallMemberPrefix }, ]; const sendRecvToDevice = [