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