trilium/src/public/javascripts/services/sync.js

30 lines
701 B
JavaScript
Raw Normal View History

2018-04-07 06:46:29 +08:00
import server from './server.js';
2019-10-20 16:00:18 +08:00
import toastService from "./toast.js";
async function syncNow() {
const result = await server.post('sync/now');
if (result.success) {
2019-10-20 16:00:18 +08:00
toastService.showMessage("Sync finished successfully.");
}
else {
if (result.message.length > 50) {
result.message = result.message.substr(0, 50);
}
2019-10-20 16:00:18 +08:00
toastService.showError("Sync failed: " + result.message);
}
}
2019-11-10 00:39:48 +08:00
$("#sync-now-button").on('click', syncNow);
async function forceNoteSync(noteId) {
2018-04-07 06:46:29 +08:00
await server.post('sync/force-note-sync/' + noteId);
2019-10-20 16:00:18 +08:00
toastService.showMessage("Note added to sync queue.");
}
export default {
syncNow,
forceNoteSync
};