mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
sync update persistent notification
This commit is contained in:
parent
edc23940d0
commit
22d48b0586
@ -1,6 +1,5 @@
|
|||||||
import utils from './utils.js';
|
import utils from './utils.js';
|
||||||
import toastService from "./toast.js";
|
import toastService from "./toast.js";
|
||||||
import treeService from "./tree.js";
|
|
||||||
|
|
||||||
const $outstandingSyncsCount = $("#outstanding-syncs-count");
|
const $outstandingSyncsCount = $("#outstanding-syncs-count");
|
||||||
|
|
||||||
@ -159,6 +158,21 @@ setTimeout(() => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
|
subscribeToMessages(message => {
|
||||||
|
if (message.type === 'sync-pull-in-progress') {
|
||||||
|
toastService.showPersistent({
|
||||||
|
id: 'sync',
|
||||||
|
title: "Sync status",
|
||||||
|
message: "Sync update in progress",
|
||||||
|
icon: "refresh"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.type === 'sync-pull-finished') {
|
||||||
|
toastService.closePersistent('sync');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
logError,
|
logError,
|
||||||
subscribeToMessages,
|
subscribeToMessages,
|
||||||
|
@ -138,6 +138,8 @@ async function pullSync(syncContext) {
|
|||||||
log.info("Pulled " + rows.length + " changes from " + changesUri + " in "
|
log.info("Pulled " + rows.length + " changes from " + changesUri + " in "
|
||||||
+ (Date.now() - startDate.getTime()) + "ms");
|
+ (Date.now() - startDate.getTime()) + "ms");
|
||||||
|
|
||||||
|
ws.syncPullInProgress();
|
||||||
|
|
||||||
for (const {sync, entity} of rows) {
|
for (const {sync, entity} of rows) {
|
||||||
if (!sourceIdService.isLocalSourceId(sync.sourceId)) {
|
if (!sourceIdService.isLocalSourceId(sync.sourceId)) {
|
||||||
await syncUpdateService.updateEntity(sync, entity, syncContext.sourceId);
|
await syncUpdateService.updateEntity(sync, entity, syncContext.sourceId);
|
||||||
@ -150,6 +152,8 @@ async function pullSync(syncContext) {
|
|||||||
await setLastSyncedPull(rows[rows.length - 1].sync.id);
|
await setLastSyncedPull(rows[rows.length - 1].sync.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ws.syncPullFinished();
|
||||||
|
|
||||||
log.info("Finished pull");
|
log.info("Finished pull");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,9 +171,6 @@ async function pushSync(syncContext) {
|
|||||||
|
|
||||||
const filteredSyncs = syncs.filter(sync => {
|
const filteredSyncs = syncs.filter(sync => {
|
||||||
if (sync.sourceId === syncContext.sourceId) {
|
if (sync.sourceId === syncContext.sourceId) {
|
||||||
// too noisy
|
|
||||||
//log.info(`Skipping push #${sync.id} ${sync.entityName} ${sync.entityId} because it originates from sync target`);
|
|
||||||
|
|
||||||
// this may set lastSyncedPush beyond what's actually sent (because of size limit)
|
// this may set lastSyncedPush beyond what's actually sent (because of size limit)
|
||||||
// so this is applied to the database only if there's no actual update
|
// so this is applied to the database only if there's no actual update
|
||||||
// TODO: it would be better to simplify this somehow
|
// TODO: it would be better to simplify this somehow
|
||||||
|
@ -99,8 +99,18 @@ async function refreshTree() {
|
|||||||
await sendMessageToAllClients({ type: 'refresh-tree' });
|
await sendMessageToAllClients({ type: 'refresh-tree' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function syncPullInProgress() {
|
||||||
|
await sendMessageToAllClients({ type: 'sync-pull-in-progress' });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function syncPullFinished() {
|
||||||
|
await sendMessageToAllClients({ type: 'sync-pull-finished' });
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
init,
|
init,
|
||||||
sendMessageToAllClients,
|
sendMessageToAllClients,
|
||||||
refreshTree
|
refreshTree,
|
||||||
|
syncPullInProgress,
|
||||||
|
syncPullFinished
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user