Skip to content

Commit

Permalink
feat: support to show call logger status (#910)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
embbnux authored Nov 5, 2024
1 parent 7fd3d39 commit 9aa5b46
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 14 deletions.
35 changes: 35 additions & 0 deletions src/components/CallItem/StatusMessage.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<StyledText
color={color}
title={message}
variant="caption1"
component="span"
>
{message}
</StyledText>
);
}
17 changes: 15 additions & 2 deletions src/components/CallItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -401,14 +402,19 @@ export const CallItem: FunctionComponent<CallItemProps> = ({

// 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) {
Expand Down Expand Up @@ -605,6 +611,13 @@ export const CallItem: FunctionComponent<CallItemProps> = ({
/>
)
}
{
statusMatch && (
<StatusMessage
statusMatch={statusMatch}
/>
)
}
</DetailArea>
<span className="call-item-time">
{dateEl}{statusEl}
Expand Down
22 changes: 19 additions & 3 deletions src/modules/CallLogger/index.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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 = {};
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/modules/CallsListUI/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 11 additions & 8 deletions src/modules/ThirdPartyService/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 {};
}
}
Expand Down Expand Up @@ -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 {};
}
}
Expand All @@ -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 {};
}
}
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -782,15 +785,15 @@ 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],
ignoreCache: true
});
}
} catch (e) {
console.error(e);
console.error('Log call error, please check if call logger responds successfully', e);
}
}

Expand Down Expand Up @@ -866,15 +869,15 @@ 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],
ignoreCache: true
});
}
} catch (e) {
console.error(e);
console.error('Log message error, please check if message logger responds successfully', e);
}
}

Expand Down

0 comments on commit 9aa5b46

Please sign in to comment.