Skip to content

Commit 8f54108

Browse files
authored
fix: recording may missed in call logger event (#1093)
* fix: recording may missed in call logger event * misc: remove unneed code
1 parent 35f2e0f commit 8f54108

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ringcentral-embeddable",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"description": "A RingCentral Embeddable Widget Application",
55
"main": "index.js",
66
"license": "MIT",

src/modules/CallLogger/index.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { computed } from '@ringcentral-integration/core';
1+
import { computed, watch } from '@ringcentral-integration/core';
22
import { Module } from '@ringcentral-integration/commons/lib/di';
33
import { CallLogger as CallLoggerBase } from '@ringcentral-integration/commons/modules/CallLogger';
44
import { isRinging } from '@ringcentral-integration/commons/lib/callLogHelpers';
@@ -66,6 +66,46 @@ export class CallLogger extends CallLoggerBase {
6666
}
6767
}
6868

69+
override onInitOnce() {
70+
super.onInitOnce();
71+
watch(
72+
this,
73+
() => this._deps.callLog.calls,
74+
(newCalls, oldCalls) => {
75+
if (!this.ready) {
76+
return;
77+
}
78+
const oldCallsMap = {};
79+
const maxOldHandledCount = oldCalls.length > 20 ? 20 : oldCalls.length;
80+
for (let i = 0; i < maxOldHandledCount; i++) {
81+
const oldCall = oldCalls[i];
82+
oldCallsMap[oldCall.telephonySessionId] = oldCall;
83+
}
84+
const maxNewHandledCount = newCalls.length > 20 ? 20 : newCalls.length;
85+
for (let i = 0; i < maxNewHandledCount; i++) {
86+
const newCall = newCalls[i];
87+
if (!newCall.recording) {
88+
continue;
89+
}
90+
const oldCall = oldCallsMap[newCall.telephonySessionId];
91+
// For new call log added, it will be handled by this._deps.callHistory.endedCalls watcher
92+
if (!oldCall) {
93+
continue;
94+
}
95+
// only handle new recording data found
96+
if (oldCall.recording) {
97+
continue;
98+
}
99+
const call = this._deps.callHistory.calls.find(call => call.telephonySessionId === newCall.telephonySessionId);
100+
if (!call) {
101+
return;
102+
}
103+
this._onCallUpdated(call, callLoggerTriggerTypes.callLogSync);
104+
}
105+
}
106+
);
107+
}
108+
69109
async getRecentUnloggedCalls({
70110
perPage = 100,
71111
page = 1,

0 commit comments

Comments
 (0)