You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-07 21:23:00 +03:00
Add ringing for matrixRTC (#11870)
* Add ringing for matrixRTC - since we are using m.mentions we start with the Notifier - an event in the Notifier will result in a IncomingCall toast - incomingCallToast is responsible for ringing (as long as one can see the toast it rings) This should make sure visual and audio signal are in sync. Signed-off-by: Timo K <toger5@hotmail.de> * use typed CallNotifyContent Signed-off-by: Timo K <toger5@hotmail.de> * update tests Signed-off-by: Timo K <toger5@hotmail.de> * change to callId Signed-off-by: Timo K <toger5@hotmail.de> * fix tests Signed-off-by: Timo K <toger5@hotmail.de> * only ring in 1:1 calls notify in rooms < 15 member Signed-off-by: Timo K <toger5@hotmail.de> * call_id fallback Signed-off-by: Timo K <toger5@hotmail.de> * Update src/Notifier.ts Co-authored-by: Robin <robin@robin.town> * review Signed-off-by: Timo K <toger5@hotmail.de> * add tests Signed-off-by: Timo K <toger5@hotmail.de> * more tests Signed-off-by: Timo K <toger5@hotmail.de> * unused import Signed-off-by: Timo K <toger5@hotmail.de> * String -> string Signed-off-by: Timo K <toger5@hotmail.de> --------- Signed-off-by: Timo K <toger5@hotmail.de> Co-authored-by: Robin <robin@robin.town>
This commit is contained in:
@@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { mocked, MockedObject } from "jest-mock";
|
||||
import {
|
||||
ClientEvent,
|
||||
@@ -29,7 +28,6 @@ import {
|
||||
import { waitFor } from "@testing-library/react";
|
||||
|
||||
import BasePlatform from "../src/BasePlatform";
|
||||
import { ElementCall } from "../src/models/Call";
|
||||
import Notifier from "../src/Notifier";
|
||||
import SettingsStore from "../src/settings/SettingsStore";
|
||||
import ToastStore from "../src/stores/ToastStore";
|
||||
@@ -44,7 +42,7 @@ import {
|
||||
mockClientMethodsUser,
|
||||
mockPlatformPeg,
|
||||
} from "./test-utils";
|
||||
import { IncomingCallToast } from "../src/toasts/IncomingCallToast";
|
||||
import { getIncomingCallToastKey, IncomingCallToast } from "../src/toasts/IncomingCallToast";
|
||||
import { SdkContextClass } from "../src/contexts/SDKContext";
|
||||
import UserActivity from "../src/UserActivity";
|
||||
import Modal from "../src/Modal";
|
||||
@@ -389,12 +387,17 @@ describe("Notifier", () => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
const callOnEvent = (type?: string) => {
|
||||
const emitCallNotifyEvent = (type?: string, roomMention = true) => {
|
||||
const callEvent = mkEvent({
|
||||
type: type ?? ElementCall.CALL_EVENT_TYPE.name,
|
||||
type: type ?? EventType.CallNotify,
|
||||
user: "@alice:foo",
|
||||
room: roomId,
|
||||
content: {},
|
||||
content: {
|
||||
"application": "m.call",
|
||||
"m.mentions": { user_ids: [], room: roomMention },
|
||||
"notify_type": "ring",
|
||||
"call_id": "abc123",
|
||||
},
|
||||
event: true,
|
||||
});
|
||||
emitLiveEvent(callEvent);
|
||||
@@ -410,15 +413,15 @@ describe("Notifier", () => {
|
||||
it("should show toast when group calls are supported", () => {
|
||||
setGroupCallsEnabled(true);
|
||||
|
||||
const callEvent = callOnEvent();
|
||||
const notifyEvent = emitCallNotifyEvent();
|
||||
|
||||
expect(ToastStore.sharedInstance().addOrReplaceToast).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
key: `call_${callEvent.getStateKey()}`,
|
||||
key: getIncomingCallToastKey(notifyEvent.getContent().call_id ?? "", roomId),
|
||||
priority: 100,
|
||||
component: IncomingCallToast,
|
||||
bodyClassName: "mx_IncomingCallToast",
|
||||
props: { callEvent },
|
||||
props: { notifyEvent },
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -426,7 +429,7 @@ describe("Notifier", () => {
|
||||
it("should not show toast when group calls are not supported", () => {
|
||||
setGroupCallsEnabled(false);
|
||||
|
||||
callOnEvent();
|
||||
emitCallNotifyEvent();
|
||||
|
||||
expect(ToastStore.sharedInstance().addOrReplaceToast).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -434,7 +437,7 @@ describe("Notifier", () => {
|
||||
it("should not show toast when calling with non-group call event", () => {
|
||||
setGroupCallsEnabled(true);
|
||||
|
||||
callOnEvent("event_type");
|
||||
emitCallNotifyEvent("event_type");
|
||||
|
||||
expect(ToastStore.sharedInstance().addOrReplaceToast).not.toHaveBeenCalled();
|
||||
});
|
||||
|
Reference in New Issue
Block a user