This commit is contained in:
Half-Shot
2024-12-19 11:02:57 +00:00
parent 3aff86c2c4
commit acef18b26d
3 changed files with 51 additions and 61 deletions
+10 -13
View File
@@ -16,7 +16,6 @@ import {
import { type MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession"; import { type MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { useObservableEagerState } from "observable-hooks"; import { useObservableEagerState } from "observable-hooks";
import { map } from "rxjs";
import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships"; import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships";
import { useClientState } from "../ClientContext"; import { useClientState } from "../ClientContext";
@@ -75,24 +74,22 @@ export const ReactionsSenderProvider = ({
: undefined; : undefined;
}, [memberships, myUserId]); }, [memberships, myUserId]);
const myReaction = useObservableEagerState( const reactions = useObservableEagerState(vm.reactions$);
vm.reactions$.pipe( const myReaction = useMemo(
map((v) => () =>
myMembershipIdentifier !== undefined myMembershipIdentifier !== undefined
? v[myMembershipIdentifier] ? reactions[myMembershipIdentifier]
: undefined, : undefined,
), [myMembershipIdentifier, reactions],
),
); );
const myRaisedHand = useObservableEagerState( const handsRaised = useObservableEagerState(vm.handsRaised$);
vm.handsRaised$.pipe( const myRaisedHand = useMemo(
map((v) => () =>
myMembershipIdentifier !== undefined myMembershipIdentifier !== undefined
? v[myMembershipIdentifier] ? handsRaised[myMembershipIdentifier]
: undefined, : undefined,
), [myMembershipIdentifier, handsRaised],
),
); );
const toggleRaisedHand = useCallback(async () => { const toggleRaisedHand = useCallback(async () => {
+1 -2
View File
@@ -805,8 +805,7 @@ it("should rank raised hands above video feeds and below speakers and presenters
(vm, { raisedHands$ }) => { (vm, { raisedHands$ }) => {
schedule("ab", { schedule("ab", {
a: () => { a: () => {
// We imagine that only three tiles (the first three) will be visible // We imagine that only two tiles (the first two) will be visible on screen at a time
// on screen at a time
vm.layout$.subscribe((layout) => { vm.layout$.subscribe((layout) => {
if (layout.type === "grid") { if (layout.type === "grid") {
layout.setVisibleTiles(2); layout.setVisibleTiles(2);
+5 -11
View File
@@ -1216,9 +1216,8 @@ export class CallViewModel extends ViewModel {
/** /**
* Emits an array of reactions that should be visible on the screen. * Emits an array of reactions that should be visible on the screen.
*/ */
public readonly visibleReactions$ = showReactions.value$ public readonly visibleReactions$ = showReactions.value$.pipe(
.pipe(switchMap((show) => (show ? this.reactions$ : of({})))) switchMap((show) => (show ? this.reactions$ : of({}))),
.pipe(
scan< scan<
Record<string, ReactionOption>, Record<string, ReactionOption>,
{ sender: string; emoji: string; startX: number }[] { sender: string; emoji: string; startX: number }[]
@@ -1232,19 +1231,15 @@ export class CallViewModel extends ViewModel {
} }
return newSet; return newSet;
}, []), }, []),
) );
.pipe(this.scope.state());
/** /**
* Emits an array of reactions that should be played. * Emits an array of reactions that should be played.
*/ */
public readonly audibleReactions$ = playReactionsSound.value$ public readonly audibleReactions$ = playReactionsSound.value$.pipe(
.pipe(
switchMap((show) => switchMap((show) =>
show ? this.reactions$ : of<Record<string, ReactionOption>>({}), show ? this.reactions$ : of<Record<string, ReactionOption>>({}),
), ),
)
.pipe(
map((reactions) => Object.values(reactions).map((v) => v.name)), map((reactions) => Object.values(reactions).map((v) => v.name)),
scan<string[], { playing: string[]; newSounds: string[] }>( scan<string[], { playing: string[]; newSounds: string[] }>(
(acc, latest) => { (acc, latest) => {
@@ -1260,8 +1255,7 @@ export class CallViewModel extends ViewModel {
{ playing: [], newSounds: [] }, { playing: [], newSounds: [] },
), ),
map((v) => v.newSounds), map((v) => v.newSounds),
) );
.pipe(this.scope.state());
/** /**
* Emits an event every time a new hand is raised in * Emits an event every time a new hand is raised in