fix: DidSendCallNotification is not emitting array anymore
This commit is contained in:
@@ -5,7 +5,6 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|||||||
Please see LICENSE in the repository root for full details.
|
Please see LICENSE in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { type IRTCNotificationContent } from "matrix-js-sdk/lib/matrixrtc";
|
|
||||||
import { describe, it } from "vitest";
|
import { describe, it } from "vitest";
|
||||||
import {
|
import {
|
||||||
EventType,
|
EventType,
|
||||||
@@ -22,6 +21,7 @@ import {
|
|||||||
localRtcMember,
|
localRtcMember,
|
||||||
} from "../../utils/test-fixtures";
|
} from "../../utils/test-fixtures";
|
||||||
import {
|
import {
|
||||||
|
type CallNotificationWrapper,
|
||||||
createCallNotificationLifecycle$,
|
createCallNotificationLifecycle$,
|
||||||
type Props as CallNotificationLifecycleProps,
|
type Props as CallNotificationLifecycleProps,
|
||||||
} from "./CallNotificationLifecycle";
|
} from "./CallNotificationLifecycle";
|
||||||
@@ -31,13 +31,13 @@ function mockRingEvent(
|
|||||||
eventId: string,
|
eventId: string,
|
||||||
lifetimeMs: number | undefined,
|
lifetimeMs: number | undefined,
|
||||||
sender = local.userId,
|
sender = local.userId,
|
||||||
): { event_id: string } & IRTCNotificationContent {
|
): CallNotificationWrapper {
|
||||||
return {
|
return {
|
||||||
event_id: eventId,
|
event_id: eventId,
|
||||||
...(lifetimeMs === undefined ? {} : { lifetime: lifetimeMs }),
|
...(lifetimeMs === undefined ? {} : { lifetime: lifetimeMs }),
|
||||||
notification_type: "ring",
|
notification_type: "ring",
|
||||||
sender,
|
sender,
|
||||||
} as unknown as { event_id: string } & IRTCNotificationContent;
|
} as unknown as CallNotificationWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("waitForCallPickup$", () => {
|
describe("waitForCallPickup$", () => {
|
||||||
@@ -50,7 +50,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
behavior("a", { a: [] }).pipe(trackEpoch()),
|
behavior("a", { a: [] }).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("10ms a", {
|
sentCallNotification$: hot("10ms a", {
|
||||||
a: [mockRingEvent("$notif1", 30)],
|
a: mockRingEvent("$notif1", 30),
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot(""),
|
receivedDecline$: hot(""),
|
||||||
options: {
|
options: {
|
||||||
@@ -82,7 +82,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("5ms a", {
|
sentCallNotification$: hot("5ms a", {
|
||||||
a: [mockRingEvent("$notif2", 100)],
|
a: mockRingEvent("$notif2", 100),
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot(""),
|
receivedDecline$: hot(""),
|
||||||
options: {
|
options: {
|
||||||
@@ -111,7 +111,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("20ms a", {
|
sentCallNotification$: hot("20ms a", {
|
||||||
a: [mockRingEvent("$notif2", 50)],
|
a: mockRingEvent("$notif2", 50),
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot(""),
|
receivedDecline$: hot(""),
|
||||||
options: {
|
options: {
|
||||||
@@ -138,7 +138,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("10ms a", {
|
sentCallNotification$: hot("10ms a", {
|
||||||
a: [mockRingEvent("$notif2", undefined)],
|
a: mockRingEvent("$notif2", undefined),
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot(""),
|
receivedDecline$: hot(""),
|
||||||
options: {
|
options: {
|
||||||
@@ -167,7 +167,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("10ms a", {
|
sentCallNotification$: hot("10ms a", {
|
||||||
a: [mockRingEvent("$notif5", 30)],
|
a: mockRingEvent("$notif5", 30),
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot(""),
|
receivedDecline$: hot(""),
|
||||||
options: {
|
options: {
|
||||||
@@ -206,7 +206,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("10ms a", {
|
sentCallNotification$: hot("10ms a", {
|
||||||
a: [mockRingEvent("$decl1", 50)],
|
a: mockRingEvent("$decl1", 50),
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot("40ms d", {
|
receivedDecline$: hot("40ms d", {
|
||||||
d: [
|
d: [
|
||||||
@@ -250,7 +250,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("10ms a", {
|
sentCallNotification$: hot("10ms a", {
|
||||||
a: [mockRingEvent("$decl", 20)],
|
a: mockRingEvent("$decl", 20),
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot("40ms d", {
|
receivedDecline$: hot("40ms d", {
|
||||||
d: [
|
d: [
|
||||||
@@ -301,7 +301,7 @@ describe("waitForCallPickup$", () => {
|
|||||||
}).pipe(trackEpoch()),
|
}).pipe(trackEpoch()),
|
||||||
),
|
),
|
||||||
sentCallNotification$: hot("10ms a", {
|
sentCallNotification$: hot("10ms a", {
|
||||||
a: [mockRingEvent("$right", 50)],
|
a: mockRingEvent("$right", 50),
|
||||||
}),
|
}),
|
||||||
receivedDecline$: hot("20ms d", {
|
receivedDecline$: hot("20ms d", {
|
||||||
d: [
|
d: [
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
type CallMembership,
|
type CallMembership,
|
||||||
type MatrixRTCSession,
|
type MatrixRTCSession,
|
||||||
MatrixRTCSessionEvent,
|
MatrixRTCSessionEvent,
|
||||||
type MatrixRTCSessionEventHandlerMap,
|
|
||||||
} from "matrix-js-sdk/lib/matrixrtc";
|
} from "matrix-js-sdk/lib/matrixrtc";
|
||||||
import {
|
import {
|
||||||
combineLatest,
|
combineLatest,
|
||||||
@@ -34,6 +33,7 @@ import {
|
|||||||
EventType,
|
EventType,
|
||||||
type Room as MatrixRoom,
|
type Room as MatrixRoom,
|
||||||
RoomEvent,
|
RoomEvent,
|
||||||
|
type IRTCNotificationContent,
|
||||||
} from "matrix-js-sdk";
|
} from "matrix-js-sdk";
|
||||||
|
|
||||||
import { type Behavior } from "../Behavior";
|
import { type Behavior } from "../Behavior";
|
||||||
@@ -46,9 +46,11 @@ export type CallPickupState =
|
|||||||
| "decline"
|
| "decline"
|
||||||
| "success"
|
| "success"
|
||||||
| null;
|
| null;
|
||||||
export type CallNotificationWrapper = Parameters<
|
|
||||||
MatrixRTCSessionEventHandlerMap[MatrixRTCSessionEvent.DidSendCallNotification]
|
export type CallNotificationWrapper = {
|
||||||
>;
|
event_id: string;
|
||||||
|
} & IRTCNotificationContent;
|
||||||
|
|
||||||
export function createSentCallNotification$(
|
export function createSentCallNotification$(
|
||||||
scope: ObservableScope,
|
scope: ObservableScope,
|
||||||
matrixRTCSession: MatrixRTCSession,
|
matrixRTCSession: MatrixRTCSession,
|
||||||
@@ -140,12 +142,12 @@ export function createCallNotificationLifecycle$({
|
|||||||
scope.behavior(
|
scope.behavior(
|
||||||
sentCallNotification$.pipe(
|
sentCallNotification$.pipe(
|
||||||
filter(
|
filter(
|
||||||
(notificationEventArgs) =>
|
(notificationEventArgs: CallNotificationWrapper | null) =>
|
||||||
// only care about new events (legacy do not have decline pattern)
|
// only care about new events (legacy do not have decline pattern)
|
||||||
notificationEventArgs?.[0].notification_type === "ring",
|
notificationEventArgs?.notification_type === "ring",
|
||||||
),
|
),
|
||||||
map((e) => e as CallNotificationWrapper),
|
map((e) => e as CallNotificationWrapper),
|
||||||
switchMap(([notificationEvent]) => {
|
switchMap((notificationEvent) => {
|
||||||
const lifetimeMs = notificationEvent?.lifetime ?? 0;
|
const lifetimeMs = notificationEvent?.lifetime ?? 0;
|
||||||
return concat(
|
return concat(
|
||||||
lifetimeMs === 0
|
lifetimeMs === 0
|
||||||
|
|||||||
Reference in New Issue
Block a user