Get to where I'm querying for mailboxes
This won't work, not in the long term, but it's a better direction. I've created proxy classes for the classes coming from the JMAP client. The issue here is that this client is likely to have a bunch of things wrong. Specifically, the standard indicates that the client can be extremely stateful, to the point where it's just getting a stream of updates and keeping most of the structure in memory. The client, as presently built, does not make it easy to honor this part of the standard, so I'm going to have to structure the client interaction differently. However, what I've done here, while interesting, is not good. The problem is that I am correctly telling the client "I need the list of mailboxes" when I render the mailbox list, but I'm not able to propogate that information back to the client since it's passed down through props. I'm going to need to separate out the client into its own class and have an eventing system of some kind between it and the app.
This commit is contained in:
parent
a93a5d84f3
commit
c17e8b9ad0
5 changed files with 103 additions and 7 deletions
17
src/App.tsx
17
src/App.tsx
|
@ -2,10 +2,10 @@ import "./App.css";
|
|||
import "bootstrap/dist/css/bootstrap.min.css";
|
||||
import * as base64 from "base-64";
|
||||
import { Client } from "jmap-client-ts";
|
||||
import { IAccount, ISession } from "jmap-client-ts/lib/types";
|
||||
import { FetchTransport } from "jmap-client-ts/lib/utils/fetch-transport";
|
||||
|
||||
import AccountList from "./AccountList";
|
||||
import { IAccount, ISession } from "./types";
|
||||
import AppLayout from "./AppLayout";
|
||||
import AuthModal from "./AuthModal";
|
||||
import React from "react";
|
||||
|
||||
|
@ -63,7 +63,15 @@ class App extends React.Component<AppProps, AppState> {
|
|||
const session = this.client.getSession();
|
||||
this.setState({
|
||||
...this.state,
|
||||
session: session,
|
||||
session: {
|
||||
...session,
|
||||
accounts: Object.fromEntries(
|
||||
Object.entries(session.accounts).map(([key, account]) => [
|
||||
key,
|
||||
{ ...account, id: key.toString(), mailboxes: [] },
|
||||
]),
|
||||
),
|
||||
},
|
||||
});
|
||||
})
|
||||
.catch((error) => console.error(error));
|
||||
|
@ -133,9 +141,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||
return (
|
||||
<div className="App">
|
||||
{this.state && this.state.session ? (
|
||||
<AccountList
|
||||
<AppLayout
|
||||
account={this.account()}
|
||||
accounts={this.state.session.accounts}
|
||||
client={this.client}
|
||||
/>
|
||||
) : (
|
||||
<AuthModal onLogin={this.onLogin}></AuthModal>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue