mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 10:55:55 +01:00
we now remember past source ids so app restart won't change anything in sync operation
This commit is contained in:
45
services/sync_table.js
Normal file
45
services/sync_table.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const sql = require('./sql');
|
||||
const source_id = require('./source_id');
|
||||
const utils = require('./utils');
|
||||
|
||||
async function addNoteSync(noteId, sourceId) {
|
||||
await addEntitySync("notes", noteId, sourceId)
|
||||
}
|
||||
|
||||
async function addNoteTreeSync(noteId, sourceId) {
|
||||
await addEntitySync("notes_tree", noteId, sourceId)
|
||||
}
|
||||
|
||||
async function addNoteReorderingSync(noteId, sourceId) {
|
||||
await addEntitySync("notes_reordering", noteId, sourceId)
|
||||
}
|
||||
|
||||
async function addNoteHistorySync(noteHistoryId, sourceId) {
|
||||
await addEntitySync("notes_history", noteHistoryId, sourceId);
|
||||
}
|
||||
|
||||
async function addOptionsSync(optName, sourceId) {
|
||||
await addEntitySync("options", optName, sourceId);
|
||||
}
|
||||
|
||||
async function addRecentNoteSync(noteId, sourceId) {
|
||||
await addEntitySync("recent_notes", noteId, sourceId);
|
||||
}
|
||||
|
||||
async function addEntitySync(entityName, entityId, sourceId) {
|
||||
await sql.replace("sync", {
|
||||
entity_name: entityName,
|
||||
entity_id: entityId,
|
||||
sync_date: utils.nowTimestamp(),
|
||||
source_id: sourceId || source_id.currentSourceId
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
addNoteSync,
|
||||
addNoteTreeSync,
|
||||
addNoteReorderingSync,
|
||||
addNoteHistorySync,
|
||||
addOptionsSync,
|
||||
addRecentNoteSync
|
||||
};
|
||||
Reference in New Issue
Block a user