You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
etesync/src/etesync-helpers.tsx

30 lines
826 B
TypeScript

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);
}