Add support for saving entries to shared journals.
parent
71e20bb65f
commit
9c740a4c4d
|
@ -26,7 +26,7 @@ import PimMain from './PimMain';
|
|||
|
||||
import { routeResolver } from '../App';
|
||||
|
||||
import { store, CredentialsData } from '../store';
|
||||
import { store, CredentialsData, UserInfoData } from '../store';
|
||||
|
||||
import { SyncInfo } from '../SyncGate';
|
||||
|
||||
|
@ -193,6 +193,7 @@ const CollectionRoutes = withRouter(
|
|||
class Pim extends React.PureComponent {
|
||||
props: {
|
||||
etesync: CredentialsData;
|
||||
userInfo: UserInfoData;
|
||||
syncInfo: SyncInfo;
|
||||
history: History;
|
||||
};
|
||||
|
@ -215,7 +216,8 @@ class Pim extends React.PureComponent {
|
|||
|
||||
let action = (originalEvent === undefined) ? EteSync.SyncEntryAction.Add : EteSync.SyncEntryAction.Change;
|
||||
let saveEvent = store.dispatch(
|
||||
createJournalEntry(this.props.etesync, journal, syncJournal.journalEntries, action, item.toIcal()));
|
||||
createJournalEntry(
|
||||
this.props.etesync, this.props.userInfo, journal, syncJournal.journalEntries, action, item.toIcal()));
|
||||
(saveEvent as any).then(() => {
|
||||
this.props.history.goBack();
|
||||
});
|
||||
|
@ -232,7 +234,8 @@ class Pim extends React.PureComponent {
|
|||
|
||||
let action = EteSync.SyncEntryAction.Delete;
|
||||
let deleteItem = store.dispatch(
|
||||
createJournalEntry(this.props.etesync, journal, syncJournal.journalEntries, action, item.toIcal()));
|
||||
createJournalEntry(
|
||||
this.props.etesync, this.props.userInfo, journal, syncJournal.journalEntries, action, item.toIcal()));
|
||||
(deleteItem as any).then(() => {
|
||||
this.props.history.push(routeResolver.getRoute('pim'));
|
||||
});
|
||||
|
|
|
@ -157,6 +157,7 @@ class SyncGate extends React.PureComponent {
|
|||
render={({match, history}) => (
|
||||
<PimRouter
|
||||
etesync={this.props.etesync}
|
||||
userInfo={this.props.userInfo.value!}
|
||||
syncInfo={journalMap}
|
||||
history={history}
|
||||
/>
|
||||
|
|
|
@ -2,11 +2,12 @@ import { List } from 'immutable';
|
|||
|
||||
import * as EteSync from './api/EteSync';
|
||||
|
||||
import { CredentialsData } from './store';
|
||||
import { CredentialsData, UserInfoData } from './store';
|
||||
import { createEntries } from './store/actions';
|
||||
|
||||
export function createJournalEntry(
|
||||
etesync: CredentialsData,
|
||||
userInfo: UserInfoData,
|
||||
journal: EteSync.Journal,
|
||||
existingEntries: List<EteSync.Entry>,
|
||||
action: EteSync.SyncEntryAction,
|
||||
|
@ -26,7 +27,15 @@ export function createJournalEntry(
|
|||
prevUid = last.uid;
|
||||
}
|
||||
|
||||
const cryptoManager = new EteSync.CryptoManager(derived, journal.uid, journal.version);
|
||||
let cryptoManager: EteSync.CryptoManager;
|
||||
if (journal.key) {
|
||||
const keyPair = userInfo.getKeyPair(new EteSync.CryptoManager(derived, 'userInfo', userInfo.version));
|
||||
const asymmetricCryptoManager = new EteSync.AsymmetricCryptoManager(keyPair);
|
||||
const derivedJournalKey = asymmetricCryptoManager.decryptBytes(journal.key);
|
||||
cryptoManager = EteSync.CryptoManager.fromDerivedKey(derivedJournalKey, journal.version);
|
||||
} else {
|
||||
cryptoManager = new EteSync.CryptoManager(derived, journal.uid, journal.version);
|
||||
}
|
||||
let entry = new EteSync.Entry();
|
||||
entry.setSyncEntry(cryptoManager, syncEntry, prevUid);
|
||||
|
||||
|
|
Loading…
Reference in New Issue