fix earpice flicker

This commit is contained in:
Timo K
2026-02-09 12:09:39 +01:00
parent 3cfb95af32
commit 8a76494682
3 changed files with 25 additions and 5 deletions

View File

@@ -616,8 +616,13 @@ export function createCallViewModel$(
const ringOverlay$ = scope.behavior( const ringOverlay$ = scope.behavior(
combineLatest([noUserToCallInRoom$, dmMember$, callPickupState$]).pipe( combineLatest([noUserToCallInRoom$, dmMember$, callPickupState$]).pipe(
map(([noUserToCallInRoom, dmMember, callPickupState]) => { map(([noUserToCallInRoom, dmMember, callPickupState]) => {
// No overlay if not in ringing state // No overlay if:
if (callPickupState !== "ringing" || noUserToCallInRoom) return null; if (
callPickupState !== "ringing" ||
noUserToCallInRoom ||
dmMember === null
)
return null;
const name = dmMember ? dmMember.rawDisplayName : matrixRoom.name; const name = dmMember ? dmMember.rawDisplayName : matrixRoom.name;
const id = dmMember ? dmMember.userId : matrixRoom.roomId; const id = dmMember ? dmMember.userId : matrixRoom.roomId;

View File

@@ -65,12 +65,12 @@ export function createDMMember$(
RoomMember, RoomMember,
"userId" | "getMxcAvatarUrl" | "rawDisplayName" "userId" | "getMxcAvatarUrl" | "rawDisplayName"
> | null> { > | null> {
// We cannot use the normal direct check from matrix since we do not have access to the account data. // We cannot use the normal direct DM check from matrix since we do not have access to the account data.
// use primitive member count === 2 check instead. // use primitive member count === 2 check instead.
return scope.behavior( return scope.behavior(
roomMembers$.pipe( roomMembers$.pipe(
map((membersMap) => { map((membersMap) => {
// primitive appraoch do to no access to account data. // primitive approach due to no access to account data.
const isDM = membersMap.size === 2; const isDM = membersMap.size === 2;
if (!isDM) return null; if (!isDM) return null;
return matrixRoom.getMember(matrixRoom.guessDMUserId()); return matrixRoom.getMember(matrixRoom.guessDMUserId());

View File

@@ -333,7 +333,22 @@ class ControlledAudioOutput implements MediaDevice<
), ),
], ],
(available, preferredId) => { (available, preferredId) => {
const id = preferredId ?? available.keys().next().value; // const preferredValid =
// preferredId !== undefined && available.has(preferredId)
// ? preferredId
// : undefined;
// // Default to speaker to prohibit toggle (speaker->earpiece->speaker)
// // - before we get `this.available$` we would use a non earpice (speaker)
// // - once we receive the available devices, we call this method need to make sure to not select earpice.
// // - the OS might select earpiece manually by calling `select` method
// const speakerId = [...available].find(
// ([, label]) => label.type === "speaker",
// )?.[0];
// const id = preferredValid ?? speakerId ?? available.keys().next().value;
const id = preferredId;
return id === undefined return id === undefined
? undefined ? undefined
: { id, virtualEarpiece: id === EARPIECE_CONFIG_ID }; : { id, virtualEarpiece: id === EARPIECE_CONFIG_ID };