node-mac-contacts icon indicating copy to clipboard operation
node-mac-contacts copied to clipboard

Get contact image by id

Open KishanBagaria opened this issue 4 years ago • 3 comments

https://github.com/KishanBagaria/node-mac-contacts/commit/e2e1f1250e6107e361734bfd6d3a0ee6aa12c927

Can create a PR if you'd like to merge upstream - might need a review

KishanBagaria avatar Mar 04 '21 18:03 KishanBagaria

Out of curiosity - what's the perf difference between this and just fetching the contact by id and pulling the single property off it?

codebytere avatar Mar 05 '21 17:03 codebytere

~~There's no fetch contact by id method exposed by node-mac-contacts?~~ I think a more generic and useful function here would be fetchContact(identifier: string, keys: string[]) which only fetches the keys specified.

Edit: if you meant just fetching thumbnailImageData or just imageData compared to the smaller-of-the-two check I'm doing here -- that's definitely implementation specific I agree and probably not a clean design for nmc. Perf benefit is substantial (either of them could be 10-100x bigger than the other.)

I was pre-fetching all contact images with getAllContacts earlier but that loads hundreds of megabytes of image data in memory for some people, so lazy loading now when needed.

KishanBagaria avatar Mar 05 '21 18:03 KishanBagaria

@KishanBagaria ah yeah sorry

I was pre-fetching all contact images with getAllContacts earlier but that loads hundreds of megabytes of image data in memory for some people, so lazy loading now when needed.

this is what i was (poorly lol) referring to. That sounds good as an abstraction - i'll poke at this a bit but feel free to open a PR and i'll take a look when i can! I'm in the middle of an international move this week though so no promises on timeline 😅

codebytere avatar Mar 08 '21 23:03 codebytere