Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filters: phoneNumbers, minTimestamp, maxTimestamp #22

Merged
merged 6 commits into from
Mar 4, 2020

Conversation

OlivierFreyssinet-old
Copy link
Contributor

@OlivierFreyssinet-old OlivierFreyssinet-old commented Oct 23, 2019

I needed some filters to avoid having to fetch the entire list of call logs and filter on the result. (To be precise I needed minTimestamp, maxTimestamp was then straightforward to implement, and I saw that someone else (#20) needed to filter by phone numbers so I also implemented it)

I made sure these filters are non breaking so the methods can be used in the same way as before.

To summarize what these filters do and how to use them, I added this to the docs:

...
/* List call logs matching the filter */
const filter = {
  minTimestamp: 1571835032,    // (Number or String) timestamp in milliseconds since UNIX epoch
                               // if this filter is set, load(limit, filter) will only return call logs with timestamp >= minTimestamp

  maxTimestamp: 1571835033,    // (Number or String) timestamp in milliseconds since UNIX epoch
                               //
                               // if this filter is set, load(limit, filter) will only return call logs with timestamp <= maxTimestamp

  phoneNumbers: '+1234567890', // (String or an Array of String)
                               // if this filter is set, load(limit, filter) will only return call logs for this/these phone numbers
}

const callLogs = await CallLogs.load(-1, filter) // applies filter with no limit (also works with a limit)
...

PS: this is in big part inspired by how the same kind of filtering is done in this other very useful module https://github.com/briankabiro/react-native-get-sms-android

@Iwouldliketobeapig
Copy link

Can i use it ? thanks

@OlivierFreyssinet-old
Copy link
Contributor Author

Sure! It would be ideal if this was merged but the repo seems to no longer be maintained so ... you could use my fork

@Iwouldliketobeapig
Copy link

Sure! It would be ideal if this was merged but the repo seems to no longer be maintained so ... you could use my fork
how can i use your's package

@OlivierFreyssinet-old
Copy link
Contributor Author

@Iwouldliketobeapig npm i github:OlivierFreyssinet/react-native-call-log --save

@aathapa aathapa merged commit 59bc27b into wscodelabs:master Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants