From 9aa5b461840d4bfd7b33bb568925bd85987e4ee2 Mon Sep 17 00:00:00 2001 From: Embbnux Ji Date: Tue, 5 Nov 2024 10:43:59 +0800 Subject: [PATCH] feat: support to show call logger status (#910) * feat: support to show call loger status * fix: remove unused module * fix: call log sync event may not sent * misc: add detail error message * fix: unlogged filtered --- src/components/CallItem/StatusMessage.tsx | 35 +++++++++++++++++++++++ src/components/CallItem/index.tsx | 17 +++++++++-- src/modules/CallLogger/index.ts | 22 ++++++++++++-- src/modules/CallsListUI/index.ts | 5 +++- src/modules/ThirdPartyService/index.ts | 19 ++++++------ 5 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 src/components/CallItem/StatusMessage.tsx diff --git a/src/components/CallItem/StatusMessage.tsx b/src/components/CallItem/StatusMessage.tsx new file mode 100644 index 00000000..3585a771 --- /dev/null +++ b/src/components/CallItem/StatusMessage.tsx @@ -0,0 +1,35 @@ +import React from 'react'; + +import { RcText, styled } from '@ringcentral/juno'; + +const StyledText = styled(RcText)` + margin-left: 8px; +`; + +export function StatusMessage({ statusMatch }) { + if (!statusMatch) { + return null; + } + const { message, status } = statusMatch; + if (!message) { + return null; + } + let color: string | undefined = undefined; + if (status === 'pending') { + color = 'warning.f02'; + } else if (status === 'failed') { + color = 'danger.f02'; + } else if (status === 'success') { + color = 'success.f02'; + } + return ( + + {message} + + ); +} diff --git a/src/components/CallItem/index.tsx b/src/components/CallItem/index.tsx index 14012411..e873ca45 100644 --- a/src/components/CallItem/index.tsx +++ b/src/components/CallItem/index.tsx @@ -44,6 +44,7 @@ import styles from '@ringcentral-integration/widgets/components/CallItem/styles. import { CallIcon } from './CallIcon'; import { RecordingDialog } from './RecordingDialog'; +import { StatusMessage } from './StatusMessage'; import { StyledListItem, @@ -401,14 +402,19 @@ export const CallItem: FunctionComponent = ({ // const selectedMatchContactType = getSelectedContact()?.type ?? ''; const actions: any[] = []; - const isLogged = activityMatches.length > 0; + const isLogged = activityMatches.length > 0 && activityMatches.find( + (activity) => activity.type !== 'status', + ); + const statusMatch = activityMatches.find( + (activity) => activity.type === 'status', + ); if (showLogButton && !isFax) { actions.push({ id: 'log', icon: isLogged ? Edit : NewAction, title: (isLogged ? 'Edit log' : logButtonTitle) || 'Log call', onClick: () => logCall(true, undefined, isLogged ? 'editLog' : 'createLog'), - disabled: disableLinks || isLogging, + disabled: disableLinks || isLogging || statusMatch && statusMatch.status === 'pending', }); } if (onClickToDial) { @@ -605,6 +611,13 @@ export const CallItem: FunctionComponent = ({ /> ) } + { + statusMatch && ( + + ) + } {dateEl}{statusEl} diff --git a/src/modules/CallLogger/index.ts b/src/modules/CallLogger/index.ts index d538e07c..ba75cca4 100644 --- a/src/modules/CallLogger/index.ts +++ b/src/modules/CallLogger/index.ts @@ -1,7 +1,7 @@ -import { computed, watch } from '@ringcentral-integration/core'; +import { computed } from '@ringcentral-integration/core'; import { Module } from '@ringcentral-integration/commons/lib/di'; import { CallLogger as CallLoggerBase } from '@ringcentral-integration/commons/modules/CallLogger'; -import { callLoggerTriggerTypes } from '@ringcentral-integration/commons/enums/callLoggerTriggerTypes'; +import { isRinging } from '@ringcentral-integration/commons/lib/callLogHelpers'; @Module({ name: 'CallLogger', @@ -26,6 +26,19 @@ export class CallLogger extends CallLoggerBase { await this._deps.thirdPartyService.logCall({ call: item, ...options }); } + async _shouldLogUpdatedCall(call) { + const isActive = await this._ensureActive(); + if (isActive && (this.logOnRinging || !isRinging(call))) { + if (this.autoLog) return true; + await this._deps.activityMatcher.triggerMatch(); + const activityMatches = + this._deps.activityMatcher.dataMapping[call.sessionId] || []; + const isLogging = !!this.loggingMap[call.sessionId]; + return activityMatches.length > 0 || isLogging; + } + return false; + } + @computed(that => [that._deps.callMonitor.calls, that._deps.callHistory.calls]) get allCallMapping() { const mapping = {}; @@ -62,7 +75,10 @@ export class CallLogger extends CallLoggerBase { return false; } const activityMatches = this._deps.activityMatcher.dataMapping[call.sessionId] || []; - if (activityMatches.length > 0) { + if ( + activityMatches.length > 0 && + activityMatches.find((match) => match.type !== 'status') + ) { return false; } // no recent 20s ended call, those calls will be handled by presenceUpdate triggerType diff --git a/src/modules/CallsListUI/index.ts b/src/modules/CallsListUI/index.ts index 9d47dd86..8ef30eb3 100644 --- a/src/modules/CallsListUI/index.ts +++ b/src/modules/CallsListUI/index.ts @@ -77,7 +77,10 @@ export class CallsListUI extends BaseCallsListUI { } return this._deps.callHistory.latestCalls.filter((call) => { if (this.filterType === 'UnLogged') { - return call.activityMatches && call.activityMatches.length === 0; + return ( + call.activityMatches && + call.activityMatches.filter(m => m.type !== 'status').length === 0 + ); } if (this.filterType === 'Missed') { return isInbound(call) && isMissed(call); diff --git a/src/modules/ThirdPartyService/index.ts b/src/modules/ThirdPartyService/index.ts index de4749f7..da92e2dc 100644 --- a/src/modules/ThirdPartyService/index.ts +++ b/src/modules/ThirdPartyService/index.ts @@ -71,6 +71,8 @@ export default class ThirdPartyService extends RcModuleV2 { private _messagesLogPageInputChangedEventPath?: string; private _customizedPageInputChangedEventPath?: string; private _doNotContactPath?: string; + private _messageLogEntityMatchSourceAdded: boolean; + private _fetchContactsPromise: Promise<{ contacts: any, syncTimestamp: number }> | null; constructor(deps) { super({ @@ -92,6 +94,7 @@ export default class ThirdPartyService extends RcModuleV2 { this._searchSourceAdded = false; this._contactMatchSourceAdded = false; this._callLogEntityMatchSourceAdded = false; + this._messageLogEntityMatchSourceAdded = false; this._recordingLink = deps.thirdPartyContactsOptions.recordingLink; } @@ -625,7 +628,7 @@ export default class ThirdPartyService extends RcModuleV2 { }); return result; } catch (e) { - console.error(e); + console.error('Match contacts error, please check if contact matcher responds successfully', e); return {}; } } @@ -665,7 +668,7 @@ export default class ThirdPartyService extends RcModuleV2 { }); return result; } catch (e) { - console.error(e); + console.error('Match call log error, please check if call log matcher responds successfully', e); return {}; } } @@ -691,7 +694,7 @@ export default class ThirdPartyService extends RcModuleV2 { }); return result; } catch (e) { - console.error(e); + console.error('Message log match error, please check if message match responds successfully', e); return {}; } } @@ -753,7 +756,7 @@ export default class ThirdPartyService extends RcModuleV2 { } await requestWithPostMessage(this._meetingLoggerPath, { meeting: formattedMeeting }, 6000); } catch (e) { - console.error(e); + console.error('Log message error, please check if meeting logger responds successfully', e); } } @@ -782,7 +785,7 @@ export default class ThirdPartyService extends RcModuleV2 { contentUri, }; } - await requestWithPostMessage(this._callLoggerPath, { call: callItem, ...options }, 6000); + await requestWithPostMessage(this._callLoggerPath, { call: callItem, ...options }, 15000); if (this._callLogEntityMatchSourceAdded) { this._deps.activityMatcher.match({ queries: [call.sessionId], @@ -790,7 +793,7 @@ export default class ThirdPartyService extends RcModuleV2 { }); } } catch (e) { - console.error(e); + console.error('Log call error, please check if call logger responds successfully', e); } } @@ -866,7 +869,7 @@ export default class ThirdPartyService extends RcModuleV2 { }); item.messages = messages; } - await requestWithPostMessage(this._messageLoggerPath, { conversation: item, ...options }, 6000); + await requestWithPostMessage(this._messageLoggerPath, { conversation: item, ...options }, 15000); if (this._messageLogEntityMatchSourceAdded) { this._deps.conversationMatcher.match({ queries: [item.conversationLogId], @@ -874,7 +877,7 @@ export default class ThirdPartyService extends RcModuleV2 { }); } } catch (e) { - console.error(e); + console.error('Log message error, please check if message logger responds successfully', e); } }