Skip to content

Instantly share code, notes, and snippets.

@neurosnap
Last active March 8, 2016 15:49
Show Gist options
  • Save neurosnap/67ccd82dc1b106360bc2 to your computer and use it in GitHub Desktop.
Save neurosnap/67ccd82dc1b106360bc2 to your computer and use it in GitHub Desktop.
async function getThreads(api, dispatch) {
try {
let mailboxes = await api.get(`mailboxes`);
mailboxes = mailboxes.mailboxes;
for (let i = 0; i < mailboxes.length; i++) {
let box = mailboxes[i];
let inbox = await api.get(`mailboxes/${box.id}/threads/folder/in`);
for (let i = 0; i < inbox.threads.length; i++) {
let thread = { ...inbox.threads[i] };
combineThreadWithPreview(thread, inbox.linked.messages);
dispatch(addThread(thread));
}
}
} catch (err) {
console.log(err);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment