diff --git a/src/SideMenu/SideMenuJournals.tsx b/src/SideMenu/SideMenuJournals.tsx
index 0a34431..9934c53 100644
--- a/src/SideMenu/SideMenuJournals.tsx
+++ b/src/SideMenu/SideMenuJournals.tsx
@@ -4,12 +4,13 @@ import { ListItem } from '../widgets/List';
import * as EteSync from '../api/EteSync';
-import { JournalsData, CredentialsData } from '../store';
+import { JournalsData, UserInfoData, CredentialsData } from '../store';
class SideMenuJournals extends React.PureComponent {
props: {
etesync: CredentialsData;
journals: JournalsData;
+ userInfo: UserInfoData;
onItemClick: (journalUid: string) => void;
};
@@ -19,35 +20,34 @@ class SideMenuJournals extends React.PureComponent {
render() {
const derived = this.props.etesync.encryptionKey;
+ let asymmetricCryptoManager: EteSync.AsymmetricCryptoManager;
const journalMap = this.props.journals.reduce(
(ret, journal) => {
- // FIXME: Skip shared journals for now
+ let cryptoManager: EteSync.CryptoManager;
if (journal.key) {
- const key = 'UNSUPPORTED';
- ret[key] = ret[key] || [];
- ret[key].push(
-
- {journal.uid.slice(0, 20)}
-
- );
+ if (!asymmetricCryptoManager) {
+ const userInfo = this.props.userInfo;
+ const keyPair = userInfo.getKeyPair(new EteSync.CryptoManager(derived, 'userInfo', userInfo.version));
+ asymmetricCryptoManager = new EteSync.AsymmetricCryptoManager(keyPair);
+ }
+ const derivedJournalKey = asymmetricCryptoManager.decryptBytes(journal.key);
+ cryptoManager = EteSync.CryptoManager.fromDerivedKey(derivedJournalKey, journal.version);
} else {
- let cryptoManager = new EteSync.CryptoManager(derived, journal.uid, journal.version);
- let info = journal.getInfo(cryptoManager);
- ret[info.type] = ret[info.type] || [];
- ret[info.type].push(
- this.props.onItemClick(journal.uid)}>
- {info.displayName} ({journal.uid.slice(0, 5)})
-
- );
+ cryptoManager = new EteSync.CryptoManager(derived, journal.uid, journal.version);
}
+ let info = journal.getInfo(cryptoManager);
+ ret[info.type] = ret[info.type] || [];
+ ret[info.type].push(
+ this.props.onItemClick(journal.uid)}>
+ {info.displayName} ({journal.uid.slice(0, 5)})
+
+ );
return ret;
},
{ CALENDAR: [],
- ADDRESS_BOOK: [],
- UNSUPPORTED: [] as Array});
+ ADDRESS_BOOK: []
+ });
return (
@@ -60,13 +60,6 @@ class SideMenuJournals extends React.PureComponent {
primaryText="Calendars"
nestedItems={journalMap.CALENDAR}
/>
-
- { journalMap.UNSUPPORTED && (
-
- )}
);
}
diff --git a/src/SideMenu/index.tsx b/src/SideMenu/index.tsx
index 1970b71..36b30b4 100644
--- a/src/SideMenu/index.tsx
+++ b/src/SideMenu/index.tsx
@@ -17,7 +17,7 @@ import ErrorBoundary from '../components/ErrorBoundary';
import { routeResolver, getPalette } from '../App';
-import { store, JournalsType, StoreState, CredentialsData } from '../store';
+import { store, JournalsType, UserInfoData, StoreState, CredentialsData } from '../store';
import { logout } from '../store/actions';
import * as C from '../constants';
@@ -29,6 +29,7 @@ interface PropsType {
interface PropsTypeInner extends PropsType {
journals: JournalsType;
+ userInfo: UserInfoData;
history: History;
}
@@ -58,7 +59,9 @@ class SideMenu extends React.PureComponent {
let loggedInItems;
if (this.props.etesync) {
- const journals = (this.props.etesync.encryptionKey && this.props.journals && this.props.journals.value) && (
+ const journals = (this.props.etesync.encryptionKey && this.props.journals && this.props.journals.value
+ && this.props.userInfo) && (
+
Journals
@@ -66,6 +69,7 @@ class SideMenu extends React.PureComponent {
@@ -113,6 +117,7 @@ class SideMenu extends React.PureComponent {
const mapStateToProps = (state: StoreState, props: PropsType) => {
return {
journals: state.cache.journals,
+ userInfo: state.cache.userInfo.value,
};
};