Add a way to create new events.
parent
e22b520b5a
commit
81c3f4d27e
@ -0,0 +1,29 @@
|
||||
import * as EteSync from './api/EteSync';
|
||||
|
||||
import { CredentialsData, createEntries } from './store';
|
||||
|
||||
export function createJournalEntry(
|
||||
etesync: CredentialsData,
|
||||
journal: EteSync.Journal,
|
||||
existingEntries: Array<EteSync.Entry>,
|
||||
content: string) {
|
||||
|
||||
let syncEntry = new EteSync.SyncEntry();
|
||||
syncEntry.action = EteSync.SyncEntryAction.Add;
|
||||
|
||||
syncEntry.content = content;
|
||||
|
||||
const derived = etesync.encryptionKey;
|
||||
let prevUid: string | null = null;
|
||||
|
||||
const entries = existingEntries;
|
||||
if (entries.length > 0) {
|
||||
prevUid = entries[entries.length - 1].uid;
|
||||
}
|
||||
|
||||
const cryptoManager = new EteSync.CryptoManager(derived, journal.uid, journal.version);
|
||||
let entry = new EteSync.Entry();
|
||||
entry.setSyncEntry(cryptoManager, syncEntry, prevUid);
|
||||
|
||||
return createEntries(etesync, journal.uid, [entry], prevUid);
|
||||
}
|
Loading…
Reference in New Issue