Select a mailbox on click, show its email IDs
We'll eventually want to populate them.
This commit is contained in:
parent
656495904b
commit
ee872f6985
5 changed files with 80 additions and 19 deletions
|
@ -65,10 +65,45 @@ export default class Client {
|
|||
return;
|
||||
}
|
||||
|
||||
emailList(accountId: string, mailboxId: string, ids: Array<string>) {}
|
||||
emailList(accountId: string, mailboxId: string, ids: Array<string>) {
|
||||
if (this.jclient == null) return;
|
||||
/*this.jclient.email_get({
|
||||
accountId: accountId,
|
||||
ids: [],
|
||||
properties: ["threadId"]
|
||||
});*/
|
||||
this.jclient
|
||||
.email_query({
|
||||
accountId: accountId,
|
||||
filter: { inMailbox: mailboxId },
|
||||
})
|
||||
.then((response) => {
|
||||
const mailbox = this.mailbox(accountId, mailboxId);
|
||||
if (mailbox == null) return;
|
||||
mailbox.emailIds = response.ids;
|
||||
this._triggerChange();
|
||||
})
|
||||
.catch(() => {
|
||||
console.error("OH NOES");
|
||||
});
|
||||
}
|
||||
|
||||
mailbox(accountId: string, mailboxId: string): IMailbox | null {
|
||||
if (this.state.session == null) return null;
|
||||
const account = this.state.session.accounts[accountId];
|
||||
if (account.mailboxes == null) return null;
|
||||
for (let i = 0; i < account.mailboxes.length; i++) {
|
||||
if (account.mailboxes[i].id === mailboxId) {
|
||||
return account.mailboxes[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
mailboxList(accountId: string, ids: Array<string>) {
|
||||
if (this.jclient == null) return;
|
||||
if (this.state.session == null) return;
|
||||
// We already populated the list
|
||||
if (this.state.session.accounts[accountId].mailboxes != null) return;
|
||||
this.jclient
|
||||
.mailbox_get({
|
||||
accountId: accountId,
|
||||
|
@ -81,7 +116,8 @@ export default class Client {
|
|||
response.list.forEach((m) => {
|
||||
mailboxes.push({
|
||||
...m,
|
||||
emails: [],
|
||||
emailIds: null,
|
||||
emails: null,
|
||||
});
|
||||
});
|
||||
account.mailboxes = mailboxes;
|
||||
|
@ -106,7 +142,7 @@ export default class Client {
|
|||
accounts: Object.fromEntries(
|
||||
Object.entries(session.accounts).map(([key, account]) => [
|
||||
key,
|
||||
{ ...account, id: key.toString(), mailboxes: [] },
|
||||
{ ...account, id: key.toString(), mailboxes: null },
|
||||
]),
|
||||
),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue