MCPcopy Create free account
hub / github.com/AlexErrant/Pentive / getNewNotesToUpload

Function getNewNotesToUpload

app/src/sqlite/note.ts:257–284  ·  view source on GitHub ↗
(noteId?: NoteId, nook?: NookId)

Source from the content-addressed store, hash-verified

255 )
256 },
257 async getNewNotesToUpload(noteId?: NoteId, nook?: NookId) {
258 const remoteTemplates = await ky
259 .selectFrom('remoteTemplate')
260 .selectAll()
261 .execute()
262 const notesAndStuff = await this.getNewNotesToUploadDom(noteId)
263 return await Promise.all(
264 notesAndStuff
265 .map(([, note]) => {
266 const remoteIds = objKeys(note.remotes)
267 .map((remoteNook) => {
268 if (nook != null && remoteNook !== nook) return null
269 const rt =
270 remoteTemplates.find(
271 (rt) =>
272 rt.localId === note.templateId && remoteNook === rt.nook,
273 ) ??
274 C.toastImpossible(
275 `No template found for id '${note.templateId}' with nook '${remoteNook}'.`,
276 )
277 return fromLDbId<RemoteTemplateId | null>(rt.remoteId)
278 })
279 .filter(notEmpty)
280 return domainToCreateRemote(note, remoteIds)
281 })
282 .map(async (n) => await remotifyNote(n).then((x) => x.note)),
283 )
284 },
285 async getNewNotesToUploadDom(noteId?: NoteId) {
286 const remoteNotes = await ky
287 .selectFrom('remoteNote')

Callers

nothing calls this directly

Calls 3

fromLDbIdFunction · 0.90
remotifyNoteFunction · 0.85
domainToCreateRemoteFunction · 0.70

Tested by

no test coverage detected