notes
All repositories: gitoria
1.8 KB
// Rejected note saves remain server state until accepted or deleted (hybriel#383).// Each login's draft is separate, so another device's conflict workflow stays unchanged.// Callers in notes.hl resolve a live, owned note before writing; all table writes are here.import { MPackDB } from 'hl:mpackdb'import { storageDir } from './util.hl'static maxDraftText = 1000000static draftsTable = new MPackDB(file = storageDir + '/drafts.db', primaryKey = 'key', indexes = ['owner', 'note'])static draftKey = (String owner, String note, String by) => { return owner + ':' + note + ':' + by }static draftsFor = (String owner, String by) => {out = []if (owner == null || by == null || by == '') { return out }for (d of draftsTable.find('owner', owner)) {if (d.by == by) { out.push({ key = d.note text = d.text base = d.base when = d.when }) }}return out}static keepDraft = (String owner, String note, String by, String text, Number base, Number when) => {if (owner == null || by == null || by == '') { return null }if (text.length > maxDraftText) { return 'the draft is too long to keep (at most ' + maxDraftText + ' characters)' }key = draftKey(owner, note, by)old = draftsTable.fetch(key)if (old != null && old.when > when) { return null }row = { =key =owner =note =by =text =base =when }stored = old == null ? draftsTable.put(row) : draftsTable.update(key, row)return stored == null ? 'could not keep the draft' : null}// A delayed acceptance must not clear a newer rejected edit.static acceptDraft = (String owner, String note, String by, Number when) => {key = draftKey(owner, note, by)old = draftsTable.fetch(key)if (old != null && old.owner == owner && old.when <= when) { draftsTable.delete(key) }}static deleteDrafts = (String owner, String note) => {for (d of draftsTable.find('note', note)) {if (d.owner == owner) { draftsTable.delete(d.key) }}}
Branches
Latest commits
- 996768bf|||PR WIP sequence note creation before provisional-id adoptionAtlas
- c49ce093|||PR WIP remove notes polling and use framework reachabilityAtlas
- c028ac61Merge branch 'notes-pr7-kunibert' into mainAtlas
- 9cc92bdfKeep conflict and history fixes while awaiting queued save supportAtlas
- a5c27cb6Allow real edits back to earlier text and honor configured identAtlas
- 15c46ced|||PR Preserve note edits, conflict bases and visible historyAtlas
- 4c6e0bf6Merge branch 'notes13-day61' into mainAtlas
- eb51864f|||PR Back/Forward via navigate, server drafts, Hybriel day61Atlas
- 3537cf7eMerge branch 'vendor-day59' into mainAtlas
- c13d188b|||PR Vendor Hybriel day59Atlas
- 24c95433Merge branch 'notes17-ghost-note' into mainAtlas
- ae1075b2Preserve rejected drafts during note ID adoptionAtlas
- 383cce23|||PR Prevent saved local edits from restoring deleted notesAtlas
- 99ca1cf6Merge branch 'vendor-day56' into mainAtlas
- 649cef37|||PR Vendor Hybriel day56Atlas
- aadd0abcMerge branch 'hl-standard-2' into mainAtlas
- 52ffac9f|||PR Keyboard and reload checks for the notes gate (HL-STANDARD F21, F5)Atlas
- 617ee8c0Merge branch 'hl-standard' into mainAtlas
- 452458ee|||PR Type the function parameters of notes' own .hl files (HL-STANDARD L10)Atlas
- 23758cd6Re-vendor complete Hybriel plugins and runtime to day44mre