Skip to content

Commit 2826bb1

Browse files
committed
Review Change and improvements
1 parent 1884c44 commit 2826bb1

File tree

6 files changed

+73
-14
lines changed

6 files changed

+73
-14
lines changed

src/components/admin/managedSettings/activityLoggingSettingPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function getActivityLoggingSettingPageRender({ adminUserSettings, crmManifest, u
4848
},
4949
logSyncFrequencySection: {
5050
type: 'object',
51-
title: 'Log sync frequency',
51+
title: 'Call Log Sync Frequency',
5252
properties: {
5353
logSyncFrequency: {
5454
type: 'object',

src/components/admin/managedSettings/customSettingsPage.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ function getCustomSettingsPageRender({ crmManifest, adminUserSettings, userSetti
2323
}
2424
for (const section of crmManifest.settings) {
2525
// Skip sections that should appear in Activity logging admin page
26-
if (section.section === 'activityLogging') {
27-
continue;
28-
}
26+
// if (section.section === 'activityLogging') {
27+
// continue;
28+
// }
2929

3030
page.schema.properties[section.id] = {
3131
type: 'string',

src/core/user.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async function refreshUserSettings({ changedSettings, isAvoidForceChange = false
9797
recordings: getShowRecordingsTabSetting(userSettings).value,
9898
contacts: getShowContactsTabSetting(userSettings).value
9999
}, '*');
100-
const autoLogMessagesGroupTrigger = (userSettings?.autoLogSMS?.value ?? false) || (userSettings?.autoLogInboundFax?.value ?? false) || (userSettings?.autoLogOutboundFax?.value ?? false);
100+
const autoLogMessagesGroupTrigger = (userSettings?.autoLogSMS?.value ?? false) || (userSettings?.autoLogInboundFax?.value ?? false) || (userSettings?.autoLogOutboundFax?.value ?? false) || (userSettings?.autoLogVoicemails?.value ?? false);
101101
const autoLogCallsGroupTrigger = (userSettings?.autoLogAnsweredIncoming?.value ?? false) || (userSettings?.autoLogMissedIncoming?.value ?? false) || (userSettings?.autoLogOutgoing?.value ?? false);
102102
RCAdapter.setAutoLog({ call: autoLogCallsGroupTrigger || (userSettings.autoLogCall?.value ?? false), message: autoLogMessagesGroupTrigger })
103103
if (!isAvoidForceChange) {

src/popup.js

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,52 @@ let platform = null;
7777
let hasOngoingCall = false;
7878
let lastUserSettingSyncDate = new Date();
7979

80+
// Helper function to determine if a call should be auto-logged based on direction and result
81+
function shouldAutoLogCall(call, userSettings) {
82+
let shouldAutoLog = false;
83+
84+
if (call.direction === 'Inbound') {
85+
if (call.result === 'Answered') {
86+
shouldAutoLog = userSettings?.autoLogAnsweredIncoming?.value ?? false;
87+
} else if (call.result === 'Missed') {
88+
shouldAutoLog = userSettings?.autoLogMissedIncoming?.value ?? false;
89+
}
90+
} else if (call.direction === 'Outbound') {
91+
shouldAutoLog = userSettings?.autoLogOutgoing?.value ?? false;
92+
}
93+
94+
// Fallback to legacy setting for backward compatibility
95+
if (!shouldAutoLog) {
96+
shouldAutoLog = userSettings?.autoLogCall?.value ?? false;
97+
}
98+
99+
return shouldAutoLog;
100+
}
101+
102+
// Helper function for presence update auto-logging (maps presence results to call results)
103+
function shouldAutoLogCallFromPresence(call, userSettings) {
104+
let shouldAutoLog = false;
105+
106+
if (call.direction === 'Inbound') {
107+
// For inbound calls: CallConnected = answered, Disconnected = missed
108+
if (call.result === 'CallConnected') {
109+
shouldAutoLog = userSettings?.autoLogAnsweredIncoming?.value ?? false;
110+
} else if (call.result === 'Disconnected') {
111+
shouldAutoLog = userSettings?.autoLogMissedIncoming?.value ?? false;
112+
}
113+
} else if (call.direction === 'Outbound') {
114+
// For outbound calls: both CallConnected and Disconnected mean call was made
115+
shouldAutoLog = userSettings?.autoLogOutgoing?.value ?? false;
116+
}
117+
118+
// Fallback to legacy setting for backward compatibility
119+
if (!shouldAutoLog) {
120+
shouldAutoLog = userSettings?.autoLogCall?.value ?? false;
121+
}
122+
123+
return shouldAutoLog;
124+
}
125+
80126
async function restartSyncInterval() {
81127
// Clear existing interval
82128
const { retroAutoCallLogIntervalId } = await chrome.storage.local.get({ retroAutoCallLogIntervalId: null });
@@ -1273,16 +1319,23 @@ window.addEventListener('message', async (e) => {
12731319
});
12741320

12751321
// Translate: If no existing call log, create condition here to navigate to auto log
1276-
if (userCore.getAutoLogCallSetting(userSettings).value && data.body.triggerType === 'callLogSync' && !(existingCalls?.length > 0 && existingCalls[0]?.matched)) {
1277-
data.body.triggerType = 'createLog';
1278-
isAutoLog = true;
1322+
if (data.body.triggerType === 'callLogSync' && !(existingCalls?.length > 0 && existingCalls[0]?.matched)) {
1323+
if (shouldAutoLogCall(data.body.call, userSettings)) {
1324+
data.body.triggerType = 'createLog';
1325+
isAutoLog = true;
1326+
}
12791327
}
12801328

12811329
// Translate: Right after call, once presence update to Disconnect, auto log the call
12821330
if (data.body.triggerType === 'presenceUpdate') {
12831331
if (data.body.call.result === 'Disconnected' || data.body.call.result === 'CallConnected') {
1284-
data.body.triggerType = 'createLog';
1285-
isAutoLog = true;
1332+
if (shouldAutoLogCallFromPresence(data.body.call, userSettings)) {
1333+
data.body.triggerType = 'createLog';
1334+
isAutoLog = true;
1335+
} else {
1336+
responseMessage(data.requestId, { data: 'ok' });
1337+
break;
1338+
}
12861339
}
12871340
else {
12881341
responseMessage(data.requestId, { data: 'ok' });

src/service/embeddableServices.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ async function getServiceManifest() {
142142
{
143143
id: "logSyncFrequency",
144144
type: "option",
145-
name: 'Log sync frequency',
145+
name: 'Call Log Sync Frequency',
146146
helper: `Specify how often you'd like to check for any unlogged calls.`,
147147
options: [
148148
{

src/service/logService.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import contactCore from '../core/contact';
55
import { showNotification, dismissNotification, isObjectEmpty, getRcAccessToken } from '../lib/util';
66
import { getLogConflictInfo } from '../lib/logUtil';
77

8+
9+
810
async function retroAutoCallLog({
911
manifest,
1012
platformName,
@@ -35,9 +37,13 @@ async function retroAutoCallLog({
3537
try {
3638
const { calls, hasMore } = await RCAdapter.getUnloggedCalls(itemsPerPage, pageNumber);
3739

38-
const isAutoLog = userCore.getAutoLogCallSetting(userSettings, isAdmin).value;
40+
// Check if any individual auto-logging setting is enabled
41+
const hasAnyAutoLogEnabled = (userSettings?.autoLogAnsweredIncoming?.value ?? false) ||
42+
(userSettings?.autoLogMissedIncoming?.value ?? false) ||
43+
(userSettings?.autoLogOutgoing?.value ?? false) ||
44+
(userSettings?.autoLogCall?.value ?? false);
3945

40-
if (!isAutoLog) {
46+
if (!hasAnyAutoLogEnabled) {
4147
return;
4248
}
4349

@@ -73,7 +79,7 @@ async function retroAutoCallLog({
7379

7480
const { hasConflict, autoSelectAdditionalSubmission } = await getLogConflictInfo({
7581
platform,
76-
isAutoLog,
82+
isAutoLog: true,
7783
contactInfo: callMatchedContact,
7884
logType: 'callLog',
7985
direction: c.direction,

0 commit comments

Comments
 (0)