From 8be76a447729aeba7f5c68f8a9bb85b4738cb76d Mon Sep 17 00:00:00 2001 From: Santhosh Vaiyapuri <3846977+santhoshvai@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:24:27 +0100 Subject: [PATCH 1/7] fix: reject was not called on timeout, decline and cancel scenarios (#1576) ## Background Currently, we don't call reject unless `reject: true` is passed on leave(). This was a recent change, so it caused a bug where reject was not called on timeout, decline, and cancel scenarios. There are four predefined reasons for rejecting the call: - `busy` - when the callee is busy and cannot accept the call. - `decline` - when the callee intentionally declines the call. - `cancel` - when the caller cancels the call. - `timeout` - when the **caller** or **callee** rejects the call after `auto_cancel_timeout_ms` or `incoming_call_timeout_ms` accordingly ## What has been done - Reject is now called on timeout, decline and cancel scenarios. We dont handle `busy` yet. Will be part of Android telecom/callkit alignment I believe. - Added reason to reject API call - `incoming_call_timeout_ms` support has been added --- packages/client/src/Call.ts | 30 +++++++++---------- .../CallControls/IncomingCallControls.tsx | 5 +++- .../CallControls/OutgoingCallControls.tsx | 5 ++-- .../Call/CallControls/RejectCallButton.tsx | 22 ++++++++++++-- .../src/utils/push/internal/utils.ts | 2 +- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/packages/client/src/Call.ts b/packages/client/src/Call.ts index cf9e207893..7b51a12680 100644 --- a/packages/client/src/Call.ts +++ b/packages/client/src/Call.ts @@ -516,20 +516,15 @@ export class Call { await waitUntilCallJoined(); } - if (reject && this.ringing) { - // I'm the one who started the call, so I should cancel it. - const hasOtherParticipants = this.state.remoteParticipants.length > 0; - if ( - this.isCreatedByMe && - !hasOtherParticipants && - callingState === CallingState.RINGING - ) { - // Signals other users that I have cancelled my call to them - // before they accepted it. - await this.reject(); - } else if (callingState === CallingState.RINGING) { - // Signals other users that I have rejected the incoming call. - await this.reject(); + if (callingState === CallingState.RINGING) { + if (reject) { + await this.reject(reason); + } else { + const hasOtherParticipants = this.state.remoteParticipants.length > 0; + if (this.isCreatedByMe && !hasOtherParticipants) { + // I'm the one who started the call, so I should cancel it when there are no other participants. + await this.reject('cancel'); + } } } @@ -1960,13 +1955,16 @@ export class Call { // ignore if the call is not ringing if (this.state.callingState !== CallingState.RINGING) return; - const timeoutInMs = settings.ring.auto_cancel_timeout_ms; + const timeoutInMs = this.isCreatedByMe + ? settings.ring.auto_cancel_timeout_ms + : settings.ring.incoming_call_timeout_ms; + // 0 means no auto-drop if (timeoutInMs <= 0) return; clearTimeout(this.dropTimeout); this.dropTimeout = setTimeout(() => { - this.leave({ reason: 'ring: timeout' }).catch((err) => { + this.leave({ reject: true, reason: 'timeout' }).catch((err) => { this.logger('error', 'Failed to drop call', err); }); }, timeoutInMs); diff --git a/packages/react-native-sdk/src/components/Call/CallControls/IncomingCallControls.tsx b/packages/react-native-sdk/src/components/Call/CallControls/IncomingCallControls.tsx index 57b74fe60b..bc376ff57c 100644 --- a/packages/react-native-sdk/src/components/Call/CallControls/IncomingCallControls.tsx +++ b/packages/react-native-sdk/src/components/Call/CallControls/IncomingCallControls.tsx @@ -28,7 +28,10 @@ export const IncomingCallControls = ({ } = useTheme(); return ( - + diff --git a/packages/react-native-sdk/src/components/Call/CallControls/OutgoingCallControls.tsx b/packages/react-native-sdk/src/components/Call/CallControls/OutgoingCallControls.tsx index 6651c517af..31e9638b41 100644 --- a/packages/react-native-sdk/src/components/Call/CallControls/OutgoingCallControls.tsx +++ b/packages/react-native-sdk/src/components/Call/CallControls/OutgoingCallControls.tsx @@ -1,9 +1,9 @@ import React from 'react'; import { StyleSheet, View } from 'react-native'; import { useTheme } from '../../../contexts'; -import { HangUpCallButton } from './HangupCallButton'; import { ToggleAudioPreviewButton } from './ToggleAudioPreviewButton'; import { ToggleVideoPreviewButton } from './ToggleVideoPreviewButton'; +import { RejectCallButton } from './RejectCallButton'; /** * Props for the OutgoingCallControls Component. @@ -32,9 +32,10 @@ export const OutgoingCallControls = ({ - ); diff --git a/packages/react-native-sdk/src/components/Call/CallControls/RejectCallButton.tsx b/packages/react-native-sdk/src/components/Call/CallControls/RejectCallButton.tsx index f97c930146..5679674efc 100644 --- a/packages/react-native-sdk/src/components/Call/CallControls/RejectCallButton.tsx +++ b/packages/react-native-sdk/src/components/Call/CallControls/RejectCallButton.tsx @@ -20,16 +20,32 @@ type RejectCallButtonProps = { * Note: If the `onPressHandler` is passed this handler will not be executed. */ onRejectCallHandler?: () => void; + /** + * Sets the height, width and border-radius (half the value) of the button. + */ + size?: React.ComponentProps['size']; + /** + * Optional: Reason for rejecting the call. + * Pass a predefined or a custom reason. + * There are four predefined reasons for rejecting the call: + - `busy` - when the callee is busy and cannot accept the call. + - `decline` - when the callee intentionally declines the call. + - `cancel` - when the caller cancels the call. + - `timeout` - when the **caller** or **callee** rejects the call after `auto_cancel_timeout_ms` or `incoming_call_timeout_ms` accordingly. + */ + rejectReason?: string; }; /** * Button to reject a call. * - * Mostly calls call.leave({ reject: true }) internally. + * Calls call.leave({ reject: true, reason: `OPTIONAL-REASON` }) internally. */ export const RejectCallButton = ({ onPressHandler, onRejectCallHandler, + size, + rejectReason, }: RejectCallButtonProps) => { const call = useCall(); const { useCallCallingState } = useCallStateHooks(); @@ -50,7 +66,7 @@ export const RejectCallButton = ({ if (callingState === CallingState.LEFT) { return; } - await call?.leave({ reject: true }); + await call?.leave({ reject: true, reason: rejectReason }); if (onRejectCallHandler) { onRejectCallHandler(); } @@ -64,7 +80,7 @@ export const RejectCallButton = ({ Date: Thu, 14 Nov 2024 11:27:20 +0000 Subject: [PATCH 2/7] chore(@stream-io/video-client): release version 1.11.1 --- packages/client/CHANGELOG.md | 7 +++++++ packages/client/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/client/CHANGELOG.md b/packages/client/CHANGELOG.md index 2a04e2c2c7..75d143e023 100644 --- a/packages/client/CHANGELOG.md +++ b/packages/client/CHANGELOG.md @@ -2,6 +2,13 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [1.11.1](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.11.0...@stream-io/video-client-1.11.1) (2024-11-14) + + +### Bug Fixes + +* reject was not called on timeout, decline and cancel scenarios ([#1576](https://github.com/GetStream/stream-video-js/issues/1576)) ([8be76a4](https://github.com/GetStream/stream-video-js/commit/8be76a447729aeba7f5c68f8a9bb85b4738cb76d)) + ## [1.11.0](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.10.5...@stream-io/video-client-1.11.0) (2024-11-13) diff --git a/packages/client/package.json b/packages/client/package.json index d15a9a179b..c3c4b2ab1b 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@stream-io/video-client", - "version": "1.11.0", + "version": "1.11.1", "packageManager": "yarn@3.2.4", "main": "dist/index.cjs.js", "module": "dist/index.es.js", From b793193cb1a8cbb11200435df720cbb609c3fea1 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot <> Date: Thu, 14 Nov 2024 11:27:43 +0000 Subject: [PATCH 3/7] chore(@stream-io/video-react-bindings): release version 1.1.18 --- packages/react-bindings/CHANGELOG.md | 5 +++++ packages/react-bindings/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/react-bindings/CHANGELOG.md b/packages/react-bindings/CHANGELOG.md index b139f67b86..6b46cc58a8 100644 --- a/packages/react-bindings/CHANGELOG.md +++ b/packages/react-bindings/CHANGELOG.md @@ -2,6 +2,11 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [1.1.18](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-1.1.17...@stream-io/video-react-bindings-1.1.18) (2024-11-14) + +### Dependency Updates + +* `@stream-io/video-client` updated to version `1.11.1` ## [1.1.17](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-bindings-1.1.16...@stream-io/video-react-bindings-1.1.17) (2024-11-13) ### Dependency Updates diff --git a/packages/react-bindings/package.json b/packages/react-bindings/package.json index 1ac26ff464..6884dd07e8 100644 --- a/packages/react-bindings/package.json +++ b/packages/react-bindings/package.json @@ -1,6 +1,6 @@ { "name": "@stream-io/video-react-bindings", - "version": "1.1.17", + "version": "1.1.18", "packageManager": "yarn@3.2.4", "main": "./dist/index.cjs.js", "module": "./dist/index.es.js", From 423c6674e35bc60ba2b69b4dca92e49b65b79786 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot <> Date: Thu, 14 Nov 2024 11:27:51 +0000 Subject: [PATCH 4/7] chore(@stream-io/video-react-sdk): release version 1.7.16 --- packages/react-sdk/CHANGELOG.md | 6 ++++++ packages/react-sdk/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/react-sdk/CHANGELOG.md b/packages/react-sdk/CHANGELOG.md index de77ac350c..e57b9c8695 100644 --- a/packages/react-sdk/CHANGELOG.md +++ b/packages/react-sdk/CHANGELOG.md @@ -2,6 +2,12 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [1.7.16](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-1.7.15...@stream-io/video-react-sdk-1.7.16) (2024-11-14) + +### Dependency Updates + +* `@stream-io/video-client` updated to version `1.11.1` +* `@stream-io/video-react-bindings` updated to version `1.1.18` ## [1.7.15](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-sdk-1.7.14...@stream-io/video-react-sdk-1.7.15) (2024-11-13) diff --git a/packages/react-sdk/package.json b/packages/react-sdk/package.json index 7d923c302b..7dd8d61a3e 100644 --- a/packages/react-sdk/package.json +++ b/packages/react-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@stream-io/video-react-sdk", - "version": "1.7.15", + "version": "1.7.16", "packageManager": "yarn@3.2.4", "main": "./dist/index.cjs.js", "module": "./dist/index.es.js", From a2fadd67f34a192767e09ec858503613ec73a52e Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot <> Date: Thu, 14 Nov 2024 11:28:08 +0000 Subject: [PATCH 5/7] chore(@stream-io/video-react-native-sdk): release version 1.3.1 --- packages/react-native-sdk/CHANGELOG.md | 11 +++++++++++ packages/react-native-sdk/package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/react-native-sdk/CHANGELOG.md b/packages/react-native-sdk/CHANGELOG.md index c9e5720c7f..cb3bc8b8c4 100644 --- a/packages/react-native-sdk/CHANGELOG.md +++ b/packages/react-native-sdk/CHANGELOG.md @@ -2,6 +2,17 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver). +## [1.3.1](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-1.3.0...@stream-io/video-react-native-sdk-1.3.1) (2024-11-14) + +### Dependency Updates + +* `@stream-io/video-client` updated to version `1.11.1` +* `@stream-io/video-react-bindings` updated to version `1.1.18` + +### Bug Fixes + +* reject was not called on timeout, decline and cancel scenarios ([#1576](https://github.com/GetStream/stream-video-js/issues/1576)) ([8be76a4](https://github.com/GetStream/stream-video-js/commit/8be76a447729aeba7f5c68f8a9bb85b4738cb76d)) + ## [1.3.0](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-1.2.15...@stream-io/video-react-native-sdk-1.3.0) (2024-11-13) diff --git a/packages/react-native-sdk/package.json b/packages/react-native-sdk/package.json index 02d56543b4..cc7b8e1323 100644 --- a/packages/react-native-sdk/package.json +++ b/packages/react-native-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@stream-io/video-react-native-sdk", - "version": "1.3.0", + "version": "1.3.1", "packageManager": "yarn@3.2.4", "main": "dist/commonjs/index.js", "module": "dist/module/index.js", From 38254b3ae7e4fe986fc496c6bf367d1afea5a2f6 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot <> Date: Thu, 14 Nov 2024 11:28:31 +0000 Subject: [PATCH 6/7] chore(@stream-io/video-react-native-dogfood): release version 4.5.1 --- sample-apps/react-native/dogfood/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample-apps/react-native/dogfood/package.json b/sample-apps/react-native/dogfood/package.json index de75f4767b..20a176ce98 100644 --- a/sample-apps/react-native/dogfood/package.json +++ b/sample-apps/react-native/dogfood/package.json @@ -1,6 +1,6 @@ { "name": "@stream-io/video-react-native-dogfood", - "version": "4.5.0", + "version": "4.5.1", "private": true, "scripts": { "android": "react-native run-android", From bcac386b6baa039b23f2281a1f7df0c633af035f Mon Sep 17 00:00:00 2001 From: Santhosh Vaiyapuri <3846977+santhoshvai@users.noreply.github.com> Date: Thu, 14 Nov 2024 14:32:09 +0100 Subject: [PATCH 7/7] chore: add reason for cancel call click button (#1577) Note: Ideally `CancelCallButton` should have been named generically as `HangupCallButton`, but would be a breaking change so I did not do it here --- .../src/components/RingingCall/RingingCallControls.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/react-sdk/src/components/RingingCall/RingingCallControls.tsx b/packages/react-sdk/src/components/RingingCall/RingingCallControls.tsx index 8e1633406b..93cb33c897 100644 --- a/packages/react-sdk/src/components/RingingCall/RingingCallControls.tsx +++ b/packages/react-sdk/src/components/RingingCall/RingingCallControls.tsx @@ -18,7 +18,10 @@ export const RingingCallControls = () => { <> call.leave({ reject: true })} + onClick={() => { + const reason = call.isCreatedByMe ? 'cancel' : 'decline'; + call.leave({ reject: true, reason }); + }} disabled={buttonsDisabled} />