diff --git a/.vscode/settings.json b/.vscode/settings.json index 6889f44..5b43834 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.insertSpaces": true, "editor.tabSize": 2 } diff --git a/package.json b/package.json index 24712ea..60ff79d 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "build-storybook": "build-storybook", "prettier:check": "prettier -c src", "prettier:format": "prettier -w src", - "lint": "eslint --max-warnings 11 src" + "lint": "eslint --max-warnings 2 src" }, "dependencies": { "@juggle/resize-observer": "^3.3.1", diff --git a/src/auth/generateRandomName.ts b/src/auth/generateRandomName.ts index fba6d9e..b58c111 100644 --- a/src/auth/generateRandomName.ts +++ b/src/auth/generateRandomName.ts @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 { uniqueNamesGenerator, adjectives, diff --git a/src/auth/useInteractiveLogin.js b/src/auth/useInteractiveLogin.js index 4b1bc54..6cdd4bd 100644 --- a/src/auth/useInteractiveLogin.js +++ b/src/auth/useInteractiveLogin.js @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 matrix, { InteractiveAuth } from "matrix-js-sdk/src/browser-index"; import { useState, useCallback } from "react"; import { useClient } from "../ClientContext"; @@ -7,39 +23,42 @@ export function useInteractiveLogin() { const { setClient } = useClient(); const [state, setState] = useState({ loading: false }); - const auth = useCallback(async (homeserver, username, password) => { - const authClient = matrix.createClient(homeserver); + const auth = useCallback( + async (homeserver, username, password) => { + const authClient = matrix.createClient(homeserver); - const interactiveAuth = new InteractiveAuth({ - matrixClient: authClient, - busyChanged(loading) { - setState((prev) => ({ ...prev, loading })); - }, - async doRequest(_auth, _background) { - return authClient.login("m.login.password", { - identifier: { - type: "m.id.user", - user: username, - }, - password, - }); - }, - }); + const interactiveAuth = new InteractiveAuth({ + matrixClient: authClient, + busyChanged(loading) { + setState((prev) => ({ ...prev, loading })); + }, + async doRequest(_auth, _background) { + return authClient.login("m.login.password", { + identifier: { + type: "m.id.user", + user: username, + }, + password, + }); + }, + }); - const { user_id, access_token, device_id } = - await interactiveAuth.attemptAuth(); + const { user_id, access_token, device_id } = + await interactiveAuth.attemptAuth(); - const client = await initClient({ - baseUrl: defaultHomeserver, - accessToken: access_token, - userId: user_id, - deviceId: device_id, - }); + const client = await initClient({ + baseUrl: defaultHomeserver, + accessToken: access_token, + userId: user_id, + deviceId: device_id, + }); - setClient(client, { user_id, access_token, device_id }); + setClient(client, { user_id, access_token, device_id }); - return client; - }, []); + return client; + }, + [setClient] + ); return [state, auth]; } diff --git a/src/auth/useInteractiveRegistration.js b/src/auth/useInteractiveRegistration.js index fce5a6d..583df1c 100644 --- a/src/auth/useInteractiveRegistration.js +++ b/src/auth/useInteractiveRegistration.js @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 matrix, { InteractiveAuth } from "matrix-js-sdk/src/browser-index"; import { useState, useEffect, useCallback, useRef } from "react"; import { useClient } from "../ClientContext"; @@ -89,7 +105,7 @@ export function useInteractiveRegistration() { return client; }, - [] + [setClient] ); return [state, register]; diff --git a/src/auth/useRecaptcha.js b/src/auth/useRecaptcha.js index d99bea2..41710bd 100644 --- a/src/auth/useRecaptcha.js +++ b/src/auth/useRecaptcha.js @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 { randomString } from "matrix-js-sdk/src/randomstring"; import { useEffect, useCallback, useRef, useState } from "react"; diff --git a/src/button/Button.jsx b/src/button/Button.jsx index 1e31fde..85754b3 100644 --- a/src/button/Button.jsx +++ b/src/button/Button.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { forwardRef } from "react"; import classNames from "classnames"; import styles from "./Button.module.css"; diff --git a/src/button/CopyButton.jsx b/src/button/CopyButton.jsx index 17483c5..b28d693 100644 --- a/src/button/CopyButton.jsx +++ b/src/button/CopyButton.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React from "react"; import useClipboard from "react-use-clipboard"; import { ReactComponent as CheckIcon } from "../icons/Check.svg"; diff --git a/src/button/LinkButton.jsx b/src/button/LinkButton.jsx index 721429d..561bba4 100644 --- a/src/button/LinkButton.jsx +++ b/src/button/LinkButton.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React from "react"; import { Link } from "react-router-dom"; import classNames from "classnames"; diff --git a/src/button/index.js b/src/button/index.js index 0dc793c..fb2cf8c 100644 --- a/src/button/index.js +++ b/src/button/index.js @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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. +*/ + export * from "./Button"; export * from "./CopyButton"; export * from "./LinkButton"; diff --git a/src/form/Form.jsx b/src/form/Form.jsx index c46064f..011fbb2 100644 --- a/src/form/Form.jsx +++ b/src/form/Form.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 classNames from "classnames"; import React, { forwardRef } from "react"; import styles from "./Form.module.css"; diff --git a/src/home/CallList.jsx b/src/home/CallList.jsx index 2e8aae6..e4badf2 100644 --- a/src/home/CallList.jsx +++ b/src/home/CallList.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React from "react"; import { Link } from "react-router-dom"; import { CopyButton } from "../button"; diff --git a/src/home/JoinExistingCallModal.jsx b/src/home/JoinExistingCallModal.jsx index 8a749f9..515baca 100644 --- a/src/home/JoinExistingCallModal.jsx +++ b/src/home/JoinExistingCallModal.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React from "react"; import { Modal, ModalContent } from "../Modal"; import { Button } from "../button"; diff --git a/src/home/RegisteredView.jsx b/src/home/RegisteredView.jsx index 0480050..02d87a1 100644 --- a/src/home/RegisteredView.jsx +++ b/src/home/RegisteredView.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { useState, useCallback } from "react"; import { createRoom, roomAliasFromRoomName } from "../matrix-utils"; import { useGroupCallRooms } from "./useGroupCallRooms"; diff --git a/src/home/UnauthenticatedView.jsx b/src/home/UnauthenticatedView.jsx index 8243510..93650b8 100644 --- a/src/home/UnauthenticatedView.jsx +++ b/src/home/UnauthenticatedView.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { useCallback, useState } from "react"; import { Header, HeaderLogo, LeftNav, RightNav } from "../Header"; import { UserMenuContainer } from "../UserMenuContainer"; diff --git a/src/home/useGroupCallRooms.js b/src/home/useGroupCallRooms.js index ea075f8..8cd0958 100644 --- a/src/home/useGroupCallRooms.js +++ b/src/home/useGroupCallRooms.js @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 { useState, useEffect } from "react"; const tsCache = {}; @@ -81,7 +97,7 @@ export function useGroupCallRooms(client) { client.removeListener("GroupCall.incoming", updateRooms); client.removeListener("GroupCall.participants", updateRooms); }; - }, []); + }, [client]); return rooms; } diff --git a/src/input/AvatarInputField.jsx b/src/input/AvatarInputField.jsx index 9b645b1..0977388 100644 --- a/src/input/AvatarInputField.jsx +++ b/src/input/AvatarInputField.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 { useObjectRef } from "@react-aria/utils"; import React, { useEffect } from "react"; import { useCallback } from "react"; diff --git a/src/input/Input.jsx b/src/input/Input.jsx index 88e0008..65d6ce3 100644 --- a/src/input/Input.jsx +++ b/src/input/Input.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { forwardRef } from "react"; import classNames from "classnames"; import styles from "./Input.module.css"; diff --git a/src/input/SelectInput.jsx b/src/input/SelectInput.jsx index 956b9e0..9cef16e 100644 --- a/src/input/SelectInput.jsx +++ b/src/input/SelectInput.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { useRef } from "react"; import { HiddenSelect, useSelect } from "@react-aria/select"; import { useButton } from "@react-aria/button"; diff --git a/src/input/Toggle.jsx b/src/input/Toggle.jsx index f742308..b6443c3 100644 --- a/src/input/Toggle.jsx +++ b/src/input/Toggle.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { useCallback, useRef } from "react"; import styles from "./Toggle.module.css"; import { useToggleButton } from "@react-aria/button"; diff --git a/src/popover/Popover.jsx b/src/popover/Popover.jsx index fe32fe6..09c73aa 100644 --- a/src/popover/Popover.jsx +++ b/src/popover/Popover.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { forwardRef, useRef } from "react"; import { DismissButton, useOverlay } from "@react-aria/overlays"; import { FocusScope } from "@react-aria/focus"; diff --git a/src/popover/PopoverMenu.jsx b/src/popover/PopoverMenu.jsx index 66ed3a7..fe7ee10 100644 --- a/src/popover/PopoverMenu.jsx +++ b/src/popover/PopoverMenu.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { forwardRef, useRef } from "react"; import styles from "./PopoverMenu.module.css"; import { useMenuTriggerState } from "@react-stately/menu"; diff --git a/src/profile/ProfileModal.jsx b/src/profile/ProfileModal.jsx index 1f757dd..b0dee0e 100644 --- a/src/profile/ProfileModal.jsx +++ b/src/profile/ProfileModal.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { useCallback, useEffect, useState } from "react"; import { Button } from "../button"; import { useProfile } from "./useProfile"; diff --git a/src/profile/useProfile.js b/src/profile/useProfile.js index aab97bf..74b2870 100644 --- a/src/profile/useProfile.js +++ b/src/profile/useProfile.js @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 { useState, useCallback, useEffect } from "react"; import { getAvatarUrl } from "../matrix-utils"; diff --git a/src/room/AudioPreview.jsx b/src/room/AudioPreview.jsx index 7cfd612..32dfd13 100644 --- a/src/room/AudioPreview.jsx +++ b/src/room/AudioPreview.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React from "react"; import styles from "./AudioPreview.module.css"; import { GroupCallState } from "matrix-js-sdk/src/webrtc/groupCall"; diff --git a/src/room/CallEndedView.jsx b/src/room/CallEndedView.jsx index 29cffbf..5bbd8b8 100644 --- a/src/room/CallEndedView.jsx +++ b/src/room/CallEndedView.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React from "react"; import styles from "./CallEndedView.module.css"; import { LinkButton } from "../button"; diff --git a/src/room/FeedbackModal.jsx b/src/room/FeedbackModal.jsx index 84338d6..3bf8517 100644 --- a/src/room/FeedbackModal.jsx +++ b/src/room/FeedbackModal.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { useCallback, useEffect } from "react"; import { Modal, ModalContent } from "../Modal"; import { Button } from "../button"; diff --git a/src/room/GridLayoutMenu.jsx b/src/room/GridLayoutMenu.jsx index a7cfd6c..2a95373 100644 --- a/src/room/GridLayoutMenu.jsx +++ b/src/room/GridLayoutMenu.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React from "react"; import { Button } from "../button"; import { PopoverMenuTrigger } from "../popover/PopoverMenu"; diff --git a/src/room/GroupCallInspector.jsx b/src/room/GroupCallInspector.jsx index b7b03d4..c3188e8 100644 --- a/src/room/GroupCallInspector.jsx +++ b/src/room/GroupCallInspector.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 { Resizable } from "re-resizable"; import React, { useEffect, diff --git a/src/room/GroupCallLoader.jsx b/src/room/GroupCallLoader.jsx index 58934d0..dd327f9 100644 --- a/src/room/GroupCallLoader.jsx +++ b/src/room/GroupCallLoader.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React from "react"; import { useLoadGroupCall } from "./useLoadGroupCall"; import { ErrorView, FullScreenView } from "../FullScreenView"; diff --git a/src/room/GroupCallView.jsx b/src/room/GroupCallView.jsx index b8052d6..0eb6b38 100644 --- a/src/room/GroupCallView.jsx +++ b/src/room/GroupCallView.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { useCallback, useEffect, useState } from "react"; import { useHistory } from "react-router-dom"; import { GroupCallState } from "matrix-js-sdk/src/webrtc/groupCall"; diff --git a/src/room/InCallView.jsx b/src/room/InCallView.jsx index ea194f0..066e296 100644 --- a/src/room/InCallView.jsx +++ b/src/room/InCallView.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { useCallback, useMemo } from "react"; import styles from "./InCallView.module.css"; import { diff --git a/src/room/InviteModal.jsx b/src/room/InviteModal.jsx index 1036f51..0a7e9ce 100644 --- a/src/room/InviteModal.jsx +++ b/src/room/InviteModal.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React from "react"; import { Modal, ModalContent } from "../Modal"; import { CopyButton } from "../button"; diff --git a/src/room/LobbyView.jsx b/src/room/LobbyView.jsx index 1797cac..7459e64 100644 --- a/src/room/LobbyView.jsx +++ b/src/room/LobbyView.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { useEffect, useRef } from "react"; import styles from "./LobbyView.module.css"; import { Button, CopyButton } from "../button"; diff --git a/src/room/OverflowMenu.jsx b/src/room/OverflowMenu.jsx index 82e7fbd..3f92975 100644 --- a/src/room/OverflowMenu.jsx +++ b/src/room/OverflowMenu.jsx @@ -1,3 +1,19 @@ +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { useCallback } from "react"; import { Button } from "../button"; import { Menu } from "../Menu"; diff --git a/src/room/PTTButton.tsx b/src/room/PTTButton.tsx index 6126b51..10f45ed 100644 --- a/src/room/PTTButton.tsx +++ b/src/room/PTTButton.tsx @@ -1,4 +1,20 @@ -import React from "react"; +/* +Copyright 2022 Matrix.org Foundation C.I.C. + +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 React, { useCallback, useEffect, useState } from "react"; import classNames from "classnames"; import styles from "./PTTButton.module.css"; @@ -26,14 +42,31 @@ export const PTTButton: React.FC = ({ startTalking, stopTalking, }) => { + const [isHeld, setHeld] = useState(false); + const onDocumentMouseUp = useCallback(() => { + if (isHeld) stopTalking(); + setHeld(false); + }, [isHeld, setHeld, stopTalking]); + + const onButtonMouseDown = useCallback(() => { + setHeld(true); + startTalking(); + }, [setHeld, startTalking]); + + useEffect(() => { + window.addEventListener("mouseup", onDocumentMouseUp); + + return () => { + window.removeEventListener("mouseup", onDocumentMouseUp); + }; + }, [onDocumentMouseUp]); return (