Compare commits

..

7 Commits

Author SHA1 Message Date
Robert Long
6a18ba0110 Use raw display names for members 2022-02-23 16:41:12 -08:00
Robert Long
0a49ddb31e Fix input prefix 2022-02-23 16:34:11 -08:00
Robert Long
25385edf12 Use a textarea in the feedback modal 2022-02-23 16:07:14 -08:00
Robert Long
721cccf152 Disable speaking indicator in 1-1 calls 2022-02-23 15:59:16 -08:00
Robert Long
3b017eb92b Add room_id and display_name to rageshakes 2022-02-23 15:52:53 -08:00
Robert Long
641b82dc45 Fix creating rooms from not found screen 2022-02-23 15:36:38 -08:00
Robert Long
42e2041d6f Fix media handler device changes 2022-02-23 15:07:51 -08:00
13 changed files with 146 additions and 44 deletions

View File

@@ -38,14 +38,25 @@ export const InputField = forwardRef(
)} )}
> >
{prefix && <span>{prefix}</span>} {prefix && <span>{prefix}</span>}
<input {type === "textarea" ? (
id={id} <textarea
{...rest} id={id}
ref={ref} {...rest}
type={type} ref={ref}
checked={checked} type={type}
disabled={disabled} disabled={disabled}
/> />
) : (
<input
id={id}
{...rest}
ref={ref}
type={type}
checked={checked}
disabled={disabled}
/>
)}
<label htmlFor={id}> <label htmlFor={id}>
{type === "checkbox" && ( {type === "checkbox" && (
<div className={styles.checkbox}> <div className={styles.checkbox}>

View File

@@ -29,7 +29,8 @@
border: 1px solid var(--inputBorderColor); border: 1px solid var(--inputBorderColor);
} }
.inputField input { .inputField input,
.inputField textarea {
font-weight: 400; font-weight: 400;
font-size: 15px; font-size: 15px;
border: none; border: none;
@@ -42,6 +43,7 @@
} }
.inputField.disabled input, .inputField.disabled input,
.inputField.disabled textarea,
.inputField.disabled span { .inputField.disabled span {
color: var(--textColor2); color: var(--textColor2);
} }
@@ -54,12 +56,14 @@
padding-right: 0; padding-right: 0;
} }
.inputField input::placeholder { .inputField input::placeholder,
.inputField textarea::placeholder {
transition: color 0.25s ease-in 0s; transition: color 0.25s ease-in 0s;
color: transparent; color: transparent;
} }
.inputField input:placeholder-shown:focus::placeholder { .inputField input:placeholder-shown:focus::placeholder,
.inputField textarea:placeholder-shown:focus::placeholder {
transition: color 0.25s ease-in 0.1s; transition: color 0.25s ease-in 0.1s;
color: var(--textColor2); color: var(--textColor2);
} }
@@ -86,13 +90,17 @@
border-color: var(--inputBorderColorFocused); border-color: var(--inputBorderColorFocused);
} }
.inputField input:focus { .inputField input:focus,
.inputField textarea:focus {
outline: 0; outline: 0;
} }
.inputField input:focus + label, .inputField input:focus + label,
.inputField input:not(:placeholder-shown) + label, .inputField input:not(:placeholder-shown) + label,
.inputField.prefix input + label { .inputField.prefix input + label,
.inputField textarea:focus + label,
.inputField textarea:not(:placeholder-shown) + label,
.inputField.prefix textarea + label {
background-color: var(--bgColor2); background-color: var(--bgColor2);
transition: font-size 0.25s ease-out 0s, color 0.25s ease-out 0s, transition: font-size 0.25s ease-out 0s, color 0.25s ease-out 0s,
top 0.25s ease-out 0s, background-color 0.25s ease-out 0s; top 0.25s ease-out 0s, background-color 0.25s ease-out 0s;
@@ -102,7 +110,8 @@
pointer-events: auto; pointer-events: auto;
} }
.inputField input:focus + label { .inputField input:focus + label,
.inputField textarea:focus + label {
color: var(--inputBorderColorFocused); color: var(--inputBorderColorFocused);
} }

View File

@@ -9,7 +9,7 @@ export function useProfile(client) {
return { return {
success: false, success: false,
loading: false, loading: false,
displayName: user?.displayName, displayName: user?.rawDisplayName,
avatarUrl: user && client && getAvatarUrl(client, user.avatarUrl), avatarUrl: user && client && getAvatarUrl(client, user.avatarUrl),
error: null, error: null,
}; };

View File

@@ -22,6 +22,7 @@ export function FeedbackModal({ inCall, roomId, ...rest }) {
description, description,
sendLogs, sendLogs,
rageshakeRequestId, rageshakeRequestId,
roomId,
}); });
if (inCall && sendLogs) { if (inCall && sendLogs) {
@@ -47,7 +48,7 @@ export function FeedbackModal({ inCall, roomId, ...rest }) {
id="description" id="description"
name="description" name="description"
label="Description (optional)" label="Description (optional)"
type="text" type="textarea"
/> />
</FieldRow> </FieldRow>
<FieldRow> <FieldRow>

View File

@@ -6,7 +6,7 @@ import { isLocalRoomId } from "../matrix-utils";
import { RoomNotFoundView } from "./RoomNotFoundView"; import { RoomNotFoundView } from "./RoomNotFoundView";
export function GroupCallLoader({ client, roomId, viaServers, children }) { export function GroupCallLoader({ client, roomId, viaServers, children }) {
const { loading, error, groupCall } = useLoadGroupCall( const { loading, error, groupCall, reload } = useLoadGroupCall(
client, client,
roomId, roomId,
viaServers viaServers
@@ -29,7 +29,9 @@ export function GroupCallLoader({ client, roomId, viaServers, children }) {
error.message.indexOf("Failed to fetch alias") !== -1)) && error.message.indexOf("Failed to fetch alias") !== -1)) &&
isLocalRoomId(roomId) isLocalRoomId(roomId)
) { ) {
return <RoomNotFoundView client={client} roomId={roomId} />; return (
<RoomNotFoundView client={client} roomId={roomId} onReload={reload} />
);
} }
if (error) { if (error) {

View File

@@ -163,6 +163,7 @@ export function InCallView({
getAvatar={renderAvatar} getAvatar={renderAvatar}
showName={items.length > 2 || item.focused} showName={items.length > 2 || item.focused}
audioOutputDevice={audioOutput} audioOutputDevice={audioOutput}
disableSpeakingIndicator={items.length < 3}
{...rest} {...rest}
/> />
)} )}
@@ -193,7 +194,10 @@ export function InCallView({
show={showInspector} show={showInspector}
/> />
{rageshakeRequestModalState.isOpen && ( {rageshakeRequestModalState.isOpen && (
<RageshakeRequestModal {...rageshakeRequestModalProps} /> <RageshakeRequestModal
{...rageshakeRequestModalProps}
roomId={roomId}
/>
)} )}
</div> </div>
); );

View File

@@ -17,7 +17,6 @@ export function OverflowMenu({
roomId, roomId,
setShowInspector, setShowInspector,
showInspector, showInspector,
client,
inCall, inCall,
groupCall, groupCall,
}) { }) {

View File

@@ -5,7 +5,7 @@ import { FieldRow, ErrorMessage } from "../input/Input";
import { useSubmitRageshake } from "../settings/rageshake"; import { useSubmitRageshake } from "../settings/rageshake";
import { Body } from "../typography/Typography"; import { Body } from "../typography/Typography";
export function RageshakeRequestModal({ rageshakeRequestId, ...rest }) { export function RageshakeRequestModal({ rageshakeRequestId, roomId, ...rest }) {
const { submitRageshake, sending, sent, error } = useSubmitRageshake(); const { submitRageshake, sending, sent, error } = useSubmitRageshake();
useEffect(() => { useEffect(() => {
@@ -27,6 +27,7 @@ export function RageshakeRequestModal({ rageshakeRequestId, ...rest }) {
submitRageshake({ submitRageshake({
sendLogs: true, sendLogs: true,
rageshakeRequestId, rageshakeRequestId,
roomId,
}) })
} }
disabled={sending} disabled={sending}

View File

@@ -8,7 +8,7 @@ import { Form } from "../form/Form";
import { useHistory } from "react-router-dom"; import { useHistory } from "react-router-dom";
import styles from "./RoomNotFoundView.module.css"; import styles from "./RoomNotFoundView.module.css";
export function RoomNotFoundView({ client, roomId }) { export function RoomNotFoundView({ client, roomId, onReload }) {
const history = useHistory(); const history = useHistory();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [error, setError] = useState(); const [error, setError] = useState();
@@ -21,11 +21,9 @@ export function RoomNotFoundView({ client, roomId }) {
setError(undefined); setError(undefined);
setLoading(true); setLoading(true);
const roomIdOrAlias = await createRoom(client, roomName); await createRoom(client, roomName);
if (roomIdOrAlias) { onReload();
history.push(`/room/${roomIdOrAlias}`);
}
} }
submit().catch((error) => { submit().catch((error) => {

View File

@@ -1,4 +1,4 @@
import { useState, useEffect } from "react"; import { useState, useEffect, useCallback } from "react";
async function fetchGroupCall( async function fetchGroupCall(
client, client,
@@ -41,14 +41,23 @@ export function useLoadGroupCall(client, roomId, viaServers) {
loading: true, loading: true,
error: undefined, error: undefined,
groupCall: undefined, groupCall: undefined,
reloadId: 0,
}); });
useEffect(() => { useEffect(() => {
setState({ loading: true }); setState({ loading: true });
fetchGroupCall(client, roomId, viaServers, 30000) fetchGroupCall(client, roomId, viaServers, 30000)
.then((groupCall) => setState({ loading: false, groupCall })) .then((groupCall) =>
.catch((error) => setState({ loading: false, error })); setState((prevState) => ({ ...prevState, loading: false, groupCall }))
}, [client, roomId]); )
.catch((error) =>
setState((prevState) => ({ ...prevState, loading: false, error }))
);
}, [client, roomId, state.reloadId]);
return state; const reload = useCallback(() => {
setState((prevState) => ({ ...prevState, reloadId: prevState.reloadId++ }));
}, []);
return { ...state, reload };
} }

View File

@@ -47,9 +47,16 @@ export function useSubmitRageshake() {
body.append("touch_input", touchInput); body.append("touch_input", touchInput);
if (client) { if (client) {
const userId = client.getUserId();
const user = client.getUser(userId);
body.append("display_name", user?.displayName);
body.append("user_id", client.credentials.userId); body.append("user_id", client.credentials.userId);
body.append("device_id", client.deviceId); body.append("device_id", client.deviceId);
if (opts.roomId) {
body.append("room_id", opts.roomId);
}
if (client.isCryptoEnabled()) { if (client.isCryptoEnabled()) {
const keys = [`ed25519:${client.getDeviceEd25519Key()}`]; const keys = [`ed25519:${client.getDeviceEd25519Key()}`];
if (client.getDeviceCurve25519Key) { if (client.getDeviceCurve25519Key) {

View File

@@ -9,6 +9,32 @@ import React, {
const MediaHandlerContext = createContext(); const MediaHandlerContext = createContext();
function getMediaPreferences() {
const mediaPreferences = localStorage.getItem("matrix-media-preferences");
if (mediaPreferences) {
try {
return JSON.parse(mediaPreferences);
} catch (e) {
return undefined;
}
} else {
return undefined;
}
}
function updateMediaPreferences(newPreferences) {
const oldPreferences = getMediaPreferences(newPreferences);
localStorage.setItem(
"matrix-media-preferences",
JSON.stringify({
...oldPreferences,
...newPreferences,
})
);
}
export function MediaHandlerProvider({ client, children }) { export function MediaHandlerProvider({ client, children }) {
const [ const [
{ {
@@ -21,8 +47,14 @@ export function MediaHandlerProvider({ client, children }) {
}, },
setState, setState,
] = useState(() => { ] = useState(() => {
const mediaPreferences = getMediaPreferences();
const mediaHandler = client.getMediaHandler(); const mediaHandler = client.getMediaHandler();
mediaHandler.restoreMediaSettings(
mediaPreferences?.audioInput,
mediaPreferences?.videoInput
);
return { return {
audioInput: mediaHandler.audioInput, audioInput: mediaHandler.audioInput,
videoInput: mediaHandler.videoInput, videoInput: mediaHandler.videoInput,
@@ -38,42 +70,67 @@ export function MediaHandlerProvider({ client, children }) {
function updateDevices() { function updateDevices() {
navigator.mediaDevices.enumerateDevices().then((devices) => { navigator.mediaDevices.enumerateDevices().then((devices) => {
const mediaPreferences = getMediaPreferences();
const audioInputs = devices.filter( const audioInputs = devices.filter(
(device) => device.kind === "audioinput" (device) => device.kind === "audioinput"
); );
const audioConnected = audioInputs.some(
(device) => device.deviceId === mediaHandler.audioInput
);
let audioInput = mediaHandler.audioInput;
if (!audioConnected && audioInputs.length > 0) {
audioInput = audioInputs[0].deviceId;
}
const videoInputs = devices.filter( const videoInputs = devices.filter(
(device) => device.kind === "videoinput" (device) => device.kind === "videoinput"
); );
const videoConnected = videoInputs.some(
(device) => device.deviceId === mediaHandler.videoInput
);
let videoInput = mediaHandler.videoInput;
if (!videoConnected && videoInputs.length > 0) {
videoInput = videoInputs[0].deviceId;
}
const audioOutputs = devices.filter( const audioOutputs = devices.filter(
(device) => device.kind === "audiooutput" (device) => device.kind === "audiooutput"
); );
let audioOutput = undefined; let audioOutput = undefined;
const audioOutputPreference = localStorage.getItem(
"matrix-audio-output"
);
if ( if (
audioOutputPreference && mediaPreferences &&
audioOutputs.some( audioOutputs.some(
(device) => device.deviceId === audioOutputPreference (device) => device.deviceId === mediaPreferences.audioOutput
) )
) { ) {
audioOutput = audioOutputPreference; audioOutput = mediaPreferences.audioOutput;
} }
if (
mediaHandler.videoInput !== videoInput ||
mediaHandler.audioInput !== audioInput
) {
mediaHandler.setMediaInputs(audioInput, videoInput);
}
updateMediaPreferences({ audioInput, videoInput, audioOutput });
setState({ setState({
audioInput: mediaHandler.audioInput, audioInput,
videoInput: mediaHandler.videoInput, videoInput,
audioOutput, audioOutput,
audioInputs, audioInputs,
audioOutputs,
videoInputs, videoInputs,
audioOutputs,
}); });
}); });
} }
updateDevices(); updateDevices();
mediaHandler.on("local_streams_changed", updateDevices); mediaHandler.on("local_streams_changed", updateDevices);
@@ -82,11 +139,13 @@ export function MediaHandlerProvider({ client, children }) {
return () => { return () => {
mediaHandler.removeListener("local_streams_changed", updateDevices); mediaHandler.removeListener("local_streams_changed", updateDevices);
navigator.mediaDevices.removeEventListener("devicechange", updateDevices); navigator.mediaDevices.removeEventListener("devicechange", updateDevices);
mediaHandler.stopAllStreams();
}; };
}, [client]); }, [client]);
const setAudioInput = useCallback( const setAudioInput = useCallback(
(deviceId) => { (deviceId) => {
updateMediaPreferences({ audioInput: deviceId });
setState((prevState) => ({ ...prevState, audioInput: deviceId })); setState((prevState) => ({ ...prevState, audioInput: deviceId }));
client.getMediaHandler().setAudioInput(deviceId); client.getMediaHandler().setAudioInput(deviceId);
}, },
@@ -95,6 +154,7 @@ export function MediaHandlerProvider({ client, children }) {
const setVideoInput = useCallback( const setVideoInput = useCallback(
(deviceId) => { (deviceId) => {
updateMediaPreferences({ videoInput: deviceId });
setState((prevState) => ({ ...prevState, videoInput: deviceId })); setState((prevState) => ({ ...prevState, videoInput: deviceId }));
client.getMediaHandler().setVideoInput(deviceId); client.getMediaHandler().setVideoInput(deviceId);
}, },
@@ -102,7 +162,7 @@ export function MediaHandlerProvider({ client, children }) {
); );
const setAudioOutput = useCallback((deviceId) => { const setAudioOutput = useCallback((deviceId) => {
localStorage.setItem("matrix-audio-output", deviceId); updateMediaPreferences({ audioOutput: deviceId });
setState((prevState) => ({ ...prevState, audioOutput: deviceId })); setState((prevState) => ({ ...prevState, audioOutput: deviceId }));
}, []); }, []);

View File

@@ -64,6 +64,7 @@ export const ParticipantsTest = () => {
key={item.id} key={item.id}
name={`User ${item.id}`} name={`User ${item.id}`}
showName={items.length > 2 || item.focused} showName={items.length > 2 || item.focused}
disableSpeakingIndicator={items.length < 3}
{...rest} {...rest}
/> />
)} )}