crabvk / bar-gmail

A Polybar module to show unread messages from Gmail
MIT License
90 stars 12 forks source link

Get total unread from users.labels.get method instead #1

Closed iwconfig closed 6 years ago

iwconfig commented 7 years ago

I have a lot of unread messages (shame on me :see_no_evil: :hear_no_evil: :speak_no_evil: :smile:).

The search result in list is only the first page. So if you have a lot of unread messages, iterating the result with the nextPageToken gives a proper count of the unread messages.

crabvk commented 7 years ago

Hello, thank you for pull request. Did you try maxResults query option? Cause iterating over pages feels like not so good solution. btw, how many unread messages you have? :slightly_smiling_face:

iwconfig commented 6 years ago

Oh, heh, you're absolutely right. Clearly i was over my head with this. I read up on the api documentation a little further and .users().labels().get(userId='me', id='INBOX').execute() gives us a dict which contains the threadsUnread key which is the total in the 'INBOX' label. This should work. No iteration occurring. 🙂 I'll update this PR soon.

Hrmm.. Heh, right now it's at 511 unread messages. Thats nothing compared to some other email accounts i own. 😄