Refactored node saving and fixed click on save icon

This commit is contained in:
Magnus Åhall 2026-06-07 12:33:08 +02:00
parent 98270b677b
commit f647d87e63
2 changed files with 32 additions and 33 deletions

View file

@ -107,11 +107,7 @@ export class App {
*/
case 'S':
this.saveNode()
/*
else if (this.page.value === 'node-properties')
this.nodeProperties.current.save()
*/
this.nodeUI.saveNode()
break
/*
@ -147,35 +143,7 @@ export class App {
return await nodeStore.get(nodeUUID)
}//}}}
async saveNode() {//{{{
if (!this.currentNode.isModified())
return
/* The node history is a local store for node history.
* This could be provisioned from the server or cleared if
* deemed unnecessary.
*
* The send queue is what will be sent back to the server
* to have a recorded history of the notes.
*
* A setting to be implemented in the future could be to
* not save the history locally at all. */
const node = this.currentNode
// The node is still in its old state and will present
// the unmodified content to the node store.
const history = nodeStore.nodesHistory.add(node)
// Prepares the node object for saving.
// Sets Updated value to current date and time.
await node.save()
// Updated node is added to the send queue to be stored on server.
const sendQueue = nodeStore.sendQueue.add(node)
// Updated node is saved to the primary node store.
const nodeStoreAdding = nodeStore.add([node])
await Promise.all([history, sendQueue, nodeStoreAdding])
}//}}}
async createNode() {//{{{
let name = prompt("Name")