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.
35 lines
902 B
TypeScript
35 lines
902 B
TypeScript
import { List } from 'immutable';
|
|
|
|
import * as EteSync from './api/EteSync';
|
|
|
|
import { CredentialsData } from './store';
|
|
import { createEntries } from './store/actions';
|
|
|
|
export function createJournalEntry(
|
|
etesync: CredentialsData,
|
|
journal: EteSync.Journal,
|
|
existingEntries: List<EteSync.Entry>,
|
|
action: EteSync.SyncEntryAction,
|
|
content: string) {
|
|
|
|
let syncEntry = new EteSync.SyncEntry();
|
|
syncEntry.action = action;
|
|
|
|
syncEntry.content = content;
|
|
|
|
const derived = etesync.encryptionKey;
|
|
let prevUid: string | null = null;
|
|
|
|
const entries = existingEntries;
|
|
const last = entries.last();
|
|
if (last) {
|
|
prevUid = last.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);
|
|
}
|