forked from wscodelabs/react-native-call-log
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallLogs.js
More file actions
25 lines (21 loc) · 777 Bytes
/
callLogs.js
File metadata and controls
25 lines (21 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { NativeModules } from 'react-native';
const {CallLogs: NativeCallLogs} = NativeModules
class CallLogs {
static async load(limit, filter) {
if (!filter) return NativeCallLogs.load(limit)
const {minTimestamp, maxTimestamp, phoneNumbers} = filter
const phoneNumbersArray = Array.isArray(phoneNumbers) ? phoneNumbers : typeof phoneNumbers === 'string' ? [phoneNumbers] : []
return NativeCallLogs.loadWithFilter(
limit,
{
minTimestamp: minTimestamp ? minTimestamp.toString() : undefined,
maxTimestamp: maxTimestamp ? maxTimestamp.toString() : undefined,
phoneNumbers: JSON.stringify(phoneNumbersArray)
}
)
}
static async loadAll() {
return NativeCallLogs.loadAll()
}
}
module.exports = CallLogs;