2018-04-06 18:46:29 -04:00
|
|
|
import server from './server.js';
|
2019-10-20 10:00:18 +02:00
|
|
|
import toastService from "./toast.js";
|
2017-11-04 21:21:09 -04:00
|
|
|
|
2018-03-25 11:09:17 -04:00
|
|
|
async function syncNow() {
|
|
|
|
|
const result = await server.post('sync/now');
|
2017-11-28 20:52:38 -05:00
|
|
|
|
2018-03-25 11:09:17 -04:00
|
|
|
if (result.success) {
|
2019-10-20 10:00:18 +02:00
|
|
|
toastService.showMessage("Sync finished successfully.");
|
2018-03-25 11:09:17 -04:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (result.message.length > 50) {
|
|
|
|
|
result.message = result.message.substr(0, 50);
|
2018-03-24 23:58:58 -04:00
|
|
|
}
|
2018-03-25 11:09:17 -04:00
|
|
|
|
2019-10-20 10:00:18 +02:00
|
|
|
toastService.showError("Sync failed: " + result.message);
|
2017-11-28 20:52:38 -05:00
|
|
|
}
|
2018-03-25 11:09:17 -04:00
|
|
|
}
|
2017-12-30 21:44:26 -05:00
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
$("#sync-now-button").on('click', syncNow);
|
2018-03-24 00:54:50 -04:00
|
|
|
|
2018-03-25 11:09:17 -04:00
|
|
|
async function forceNoteSync(noteId) {
|
2018-04-06 18:46:29 -04:00
|
|
|
await server.post('sync/force-note-sync/' + noteId);
|
2018-03-24 23:58:58 -04:00
|
|
|
|
2019-10-20 10:00:18 +02:00
|
|
|
toastService.showMessage("Note added to sync queue.");
|
2018-03-25 11:09:17 -04:00
|
|
|
}
|
2017-12-30 21:44:26 -05:00
|
|
|
|
2018-03-25 11:09:17 -04:00
|
|
|
export default {
|
|
|
|
|
syncNow,
|
|
|
|
|
forceNoteSync
|
|
|
|
|
};
|