Hand raise feature (#2542)
* Initial support for Hand Raise feature Signed-off-by: Milton Moura <miltonmoura@gmail.com> * Refactored to use reaction and redaction events Signed-off-by: Milton Moura <miltonmoura@gmail.com> * Replacing button svg with raised hand emoji Signed-off-by: Milton Moura <miltonmoura@gmail.com> * SpotlightTile should not duplicate the raised hand Signed-off-by: Milton Moura <miltonmoura@gmail.com> * Update src/room/useRaisedHands.tsx Element Call recently changed to AGPL-3.0 * Use relations to load existing reactions when joining the call Signed-off-by: Milton Moura <miltonmoura@gmail.com> * Links to sha commit of matrix-js-sdk that exposes the call membership event id and refactors some async code Signed-off-by: Milton Moura <miltonmoura@gmail.com> * Removing RaiseHand.svg * Check for reaction & redaction capabilities in widget mode Signed-off-by: Milton Moura <miltonmoura@gmail.com> * Fix failing GridTile test Signed-off-by: Milton Moura <miltonmoura@gmail.com> * Center align hand raise. * Add support for displaying the duration of a raised hand. * Add a sound for when a hand is raised. * Refactor raised hand indicator and add tests. * lint * Refactor into own files. * Redact the right thing. * Tidy up useEffect * Lint tests * Remove extra layer * Add better sound. (woosh) * Add a small mode for spotlight * Fix timestamp calculation on relaod. * Fix call border resizing video * lint * Fix and update tests * Allow timer to be configurable. * Add preferences tab for choosing to enable timer. * Drop border from raised hand icon * Handle cases when a new member event happens. * Prevent infinite loop * Major refactor to support various state problems. * Tidy up and finish test rewrites * Add some explanation comments. * Even more comments. * Use proper duration formatter * Remove rerender * Fix redactions not working because they pick up events in transit. * More tidying * Use deferred value * linting * Add tests for cases where we got a reaction from someone else. * Be even less brittle. * Transpose border to GridTile. * lint --------- Signed-off-by: Milton Moura <miltonmoura@gmail.com> Co-authored-by: fkwp <fkwp@users.noreply.github.com> Co-authored-by: Half-Shot <will@half-shot.uk> Co-authored-by: Will Hunt <github@half-shot.uk>
This commit is contained in:
@@ -25,6 +25,7 @@ import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ISyncStateData, SyncState } from "matrix-js-sdk/src/sync";
|
||||
import { MatrixError } from "matrix-js-sdk/src/matrix";
|
||||
import { WidgetApi } from "matrix-widget-api";
|
||||
|
||||
import { ErrorView } from "./FullScreenView";
|
||||
import { fallbackICEServerAllowed, initClient } from "./utils/matrix";
|
||||
@@ -52,6 +53,9 @@ export type ValidClientState = {
|
||||
// 'Disconnected' rather than 'connected' because it tracks specifically
|
||||
// whether the client is supposed to be connected but is not
|
||||
disconnected: boolean;
|
||||
supportedFeatures: {
|
||||
reactions: boolean;
|
||||
};
|
||||
setClient: (params?: SetClientParams) => void;
|
||||
};
|
||||
|
||||
@@ -188,11 +192,11 @@ export const ClientProvider: FC<Props> = ({ children }) => {
|
||||
saveSession({ ...session, passwordlessUser: false });
|
||||
|
||||
setInitClientState({
|
||||
client: initClientState.client,
|
||||
...initClientState,
|
||||
passwordlessUser: false,
|
||||
});
|
||||
},
|
||||
[initClientState?.client],
|
||||
[initClientState],
|
||||
);
|
||||
|
||||
const setClient = useCallback(
|
||||
@@ -206,6 +210,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
|
||||
if (clientParams) {
|
||||
saveSession(clientParams.session);
|
||||
setInitClientState({
|
||||
widgetApi: null,
|
||||
client: clientParams.client,
|
||||
passwordlessUser: clientParams.session.passwordlessUser,
|
||||
});
|
||||
@@ -254,6 +259,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
|
||||
);
|
||||
|
||||
const [isDisconnected, setIsDisconnected] = useState(false);
|
||||
const [supportsReactions, setSupportsReactions] = useState(false);
|
||||
|
||||
const state: ClientState | undefined = useMemo(() => {
|
||||
if (alreadyOpenedErr) {
|
||||
@@ -277,6 +283,9 @@ export const ClientProvider: FC<Props> = ({ children }) => {
|
||||
authenticated,
|
||||
setClient,
|
||||
disconnected: isDisconnected,
|
||||
supportedFeatures: {
|
||||
reactions: supportsReactions,
|
||||
},
|
||||
};
|
||||
}, [
|
||||
alreadyOpenedErr,
|
||||
@@ -285,6 +294,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
|
||||
logout,
|
||||
setClient,
|
||||
isDisconnected,
|
||||
supportsReactions,
|
||||
]);
|
||||
|
||||
const onSync = useCallback(
|
||||
@@ -309,6 +319,30 @@ export const ClientProvider: FC<Props> = ({ children }) => {
|
||||
initClientState.client.on(ClientEvent.Sync, onSync);
|
||||
}
|
||||
|
||||
if (initClientState.widgetApi) {
|
||||
const reactSend = initClientState.widgetApi.hasCapability(
|
||||
"org.matrix.msc2762.send.event:m.reaction",
|
||||
);
|
||||
const redactSend = initClientState.widgetApi.hasCapability(
|
||||
"org.matrix.msc2762.send.event:m.room.redaction",
|
||||
);
|
||||
const reactRcv = initClientState.widgetApi.hasCapability(
|
||||
"org.matrix.msc2762.receive.event:m.reaction",
|
||||
);
|
||||
const redactRcv = initClientState.widgetApi.hasCapability(
|
||||
"org.matrix.msc2762.receive.event:m.room.redaction",
|
||||
);
|
||||
|
||||
if (!reactSend || !reactRcv || !redactSend || !redactRcv) {
|
||||
logger.warn("Widget does not support reactions");
|
||||
setSupportsReactions(false);
|
||||
} else {
|
||||
setSupportsReactions(true);
|
||||
}
|
||||
} else {
|
||||
setSupportsReactions(true);
|
||||
}
|
||||
|
||||
return (): void => {
|
||||
if (initClientState.client) {
|
||||
initClientState.client.removeListener(ClientEvent.Sync, onSync);
|
||||
@@ -326,6 +360,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
|
||||
};
|
||||
|
||||
type InitResult = {
|
||||
widgetApi: WidgetApi | null;
|
||||
client: MatrixClient;
|
||||
passwordlessUser: boolean;
|
||||
};
|
||||
@@ -336,6 +371,7 @@ async function loadClient(): Promise<InitResult | null> {
|
||||
logger.log("Using a matryoshka client");
|
||||
const client = await widget.client;
|
||||
return {
|
||||
widgetApi: widget.api,
|
||||
client,
|
||||
passwordlessUser: false,
|
||||
};
|
||||
@@ -364,6 +400,7 @@ async function loadClient(): Promise<InitResult | null> {
|
||||
try {
|
||||
const client = await initClient(initClientParams, true);
|
||||
return {
|
||||
widgetApi: null,
|
||||
client,
|
||||
passwordlessUser,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user