mirror of
https://github.com/zadam/trilium.git
synced 2025-02-22 14:03:36 +08:00
Merge remote-tracking branch 'origin/stable' into next
# Conflicts: # package-lock.json # package.json
This commit is contained in:
commit
9645a07f2f
7 changed files with 32 additions and 28 deletions
|
@ -11,32 +11,32 @@ CREATE TABLE IF NOT EXISTS "mig_entity_changes" (
|
|||
INSERT INTO mig_entity_changes (id, entityName, entityId, hash, sourceId, isSynced, utcDateChanged, isErased)
|
||||
SELECT id, entityName, entityId, '', sourceId, isSynced, utcChangedDate, 0 FROM entity_changes;
|
||||
|
||||
UPDATE mig_entity_changes SET isErased = (SELECT isErased FROM notes WHERE noteId = entityId) WHERE entityName = 'notes';
|
||||
UPDATE mig_entity_changes SET isErased = COALESCE((SELECT isErased FROM notes WHERE noteId = entityId), 0) WHERE entityName = 'notes';
|
||||
UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateModified FROM notes WHERE noteId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'notes';
|
||||
|
||||
UPDATE mig_entity_changes SET isErased = (SELECT isErased FROM notes WHERE noteId = entityId) WHERE entityName = 'note_contents';
|
||||
UPDATE mig_entity_changes SET isErased = COALESCE((SELECT isErased FROM notes WHERE noteId = entityId), 0) WHERE entityName = 'note_contents';
|
||||
|
||||
UPDATE mig_entity_changes SET isErased = (
|
||||
UPDATE mig_entity_changes SET isErased = COALESCE((
|
||||
SELECT isErased
|
||||
FROM attributes
|
||||
JOIN notes USING(noteId)
|
||||
WHERE attributeId = entityId
|
||||
) WHERE entityName = 'attributes';
|
||||
), 0) WHERE entityName = 'attributes';
|
||||
UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateModified FROM attributes WHERE attributeId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'attributes';
|
||||
|
||||
UPDATE mig_entity_changes SET isErased = (
|
||||
UPDATE mig_entity_changes SET isErased = COALESCE((
|
||||
SELECT isErased
|
||||
FROM branches
|
||||
JOIN notes USING(noteId)
|
||||
WHERE branchId = entityId
|
||||
) WHERE entityName = 'branches';
|
||||
), 0) WHERE entityName = 'branches';
|
||||
UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateModified FROM branches WHERE branchId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'branches';
|
||||
|
||||
UPDATE mig_entity_changes SET isErased = (
|
||||
UPDATE mig_entity_changes SET isErased = COALESCE((
|
||||
SELECT isErased
|
||||
FROM note_revisions
|
||||
WHERE noteRevisionId = entityId
|
||||
) WHERE entityName = 'note_revisions';
|
||||
), 0) WHERE entityName = 'note_revisions';
|
||||
UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateModified FROM note_revisions WHERE noteRevisionId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'note_revisions';
|
||||
|
||||
UPDATE mig_entity_changes SET utcDateChanged = COALESCE((SELECT utcDateCreated FROM api_tokens WHERE apiTokenId = entityId), '2020-12-14 14:07:05.165Z') WHERE entityName = 'api_tokens';
|
||||
|
|
|
@ -65,7 +65,7 @@ export default class LinkMap {
|
|||
|
||||
await froca.getNotes(Array.from(noteIds));
|
||||
|
||||
// pre-fetch the link titles, it's important to have hte construction afterwards synchronous
|
||||
// pre-fetch the link titles, it's important to have the construction afterwards synchronous
|
||||
// since jsPlumb caculates width of the element
|
||||
const $linkTitles = {};
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import toastService from "../services/toast.js";
|
|||
import ws from "../services/ws.js";
|
||||
import options from "../services/options.js";
|
||||
import syncService from "../services/sync.js";
|
||||
import appContext from "../services/app_context.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="sync-status-widget">
|
||||
|
@ -108,7 +107,7 @@ export default class SyncStatusWidget extends BasicWidget {
|
|||
|
||||
showIcon(className) {
|
||||
if (!options.get('syncServerHost')) {
|
||||
this.$widget.hide();
|
||||
this.toggleInt(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -127,29 +126,31 @@ export default class SyncStatusWidget extends BasicWidget {
|
|||
});
|
||||
|
||||
this.syncState = 'in-progress';
|
||||
this.allChangesPushed = false;
|
||||
this.lastSyncedPush = message.lastSyncedPush;
|
||||
}
|
||||
else if (message.type === 'sync-push-in-progress') {
|
||||
this.syncState = 'in-progress';
|
||||
this.allChangesPushed = false;
|
||||
this.lastSyncedPush = message.lastSyncedPush;
|
||||
}
|
||||
else if (message.type === 'sync-finished') {
|
||||
// this gives user a chance to see the toast in case of fast sync finish
|
||||
setTimeout(() => toastService.closePersistent('sync'), 1000);
|
||||
|
||||
this.syncState = 'connected';
|
||||
this.lastSyncedPush = message.lastSyncedPush;
|
||||
}
|
||||
else if (message.type === 'sync-failed') {
|
||||
this.syncState = 'disconnected';
|
||||
this.lastSyncedPush = message.lastSyncedPush;
|
||||
}
|
||||
else if (message.type === 'frontend-update') {
|
||||
const {lastSyncedPush} = message.data;
|
||||
|
||||
this.allChangesPushed = lastSyncedPush === ws.getMaxKnownEntityChangeSyncId();
|
||||
this.lastSyncedPush = message.data.lastSyncedPush;
|
||||
}
|
||||
|
||||
if (this.syncState === 'unknown') {
|
||||
this.showIcon('unknown');
|
||||
this.allChangesPushed = this.lastSyncedPush === ws.getMaxKnownEntityChangeSyncId();
|
||||
|
||||
if (['unknown', 'in-progress'].includes(this.syncState)) {
|
||||
this.showIcon(this.syncState);
|
||||
} else {
|
||||
this.showIcon(this.syncState + '-' + (this.allChangesPushed ? 'no-changes' : 'with-changes'));
|
||||
}
|
||||
|
|
|
@ -111,8 +111,6 @@ function forceNoteSync(req) {
|
|||
entityChangesService.moveEntityChangeToTop('note_revision_contents', noteRevisionId);
|
||||
}
|
||||
|
||||
entityChangesService.moveEntityChangeToTop('recent_changes', noteId);
|
||||
|
||||
log.info("Forcing note sync for " + noteId);
|
||||
|
||||
// not awaiting for the job to finish (will probably take a long time)
|
||||
|
|
|
@ -48,9 +48,11 @@ function addNoteReorderingEntityChange(parentNoteId, sourceId) {
|
|||
}
|
||||
|
||||
function moveEntityChangeToTop(entityName, entityId) {
|
||||
const [hash, isSynced] = sql.getRow(`SELECT * FROM entity_changes WHERE entityName = ? AND entityId = ?`, [entityName, entityId]);
|
||||
const ec = sql.getRow(`SELECT * FROM entity_changes WHERE entityName = ? AND entityId = ?`, [entityName, entityId]);
|
||||
|
||||
addEntityChange(entityName, entityId, hash, null, isSynced);
|
||||
const localEntityChange = insertEntityChange(entityName, entityId, ec.hash, ec.isErased, ec.utcDateChanged, ec.sourceId, ec.isSynced);
|
||||
|
||||
cls.addEntityChange(localEntityChange);
|
||||
}
|
||||
|
||||
function addEntityChangesForSector(entityName, sector) {
|
||||
|
|
|
@ -334,6 +334,7 @@ function getEntityChangesRecords(entityChanges) {
|
|||
const entity = getEntityChangeRow(entityChange.entityName, entityChange.entityId);
|
||||
|
||||
if (entityChange.entityName === 'options' && !entity.isSynced) {
|
||||
// if non-synced entities should count towards "lastSyncedPush"
|
||||
records.push({entityChange});
|
||||
|
||||
continue;
|
||||
|
@ -358,7 +359,8 @@ function getLastSyncedPull() {
|
|||
}
|
||||
|
||||
function setLastSyncedPull(entityChangeId) {
|
||||
optionService.setOption('lastSyncedPull', entityChangeId);
|
||||
// this way we avoid updating entity_changes which otherwise means that we've never pushed all entity_changes
|
||||
sql.execute("UPDATE options SET value = ? WHERE name = ?", [entityChangeId, 'lastSyncedPull']);
|
||||
}
|
||||
|
||||
function getLastSyncedPush() {
|
||||
|
@ -372,7 +374,8 @@ function getLastSyncedPush() {
|
|||
function setLastSyncedPush(entityChangeId) {
|
||||
ws.setLastSyncedPush(entityChangeId);
|
||||
|
||||
optionService.setOption('lastSyncedPush', entityChangeId);
|
||||
// this way we avoid updating entity_changes which otherwise means that we've never pushed all entity_changes
|
||||
sql.execute("UPDATE options SET value = ? WHERE name = ?", [entityChangeId, 'lastSyncedPush']);
|
||||
}
|
||||
|
||||
function getMaxEntityChangeId() {
|
||||
|
|
|
@ -131,19 +131,19 @@ function sendTransactionEntityChangesToAllClients() {
|
|||
}
|
||||
|
||||
function syncPullInProgress() {
|
||||
sendMessageToAllClients({ type: 'sync-pull-in-progress' });
|
||||
sendMessageToAllClients({ type: 'sync-pull-in-progress', lastSyncedPush });
|
||||
}
|
||||
|
||||
function syncPushInProgress() {
|
||||
sendMessageToAllClients({ type: 'sync-push-in-progress' });
|
||||
sendMessageToAllClients({ type: 'sync-push-in-progress', lastSyncedPush });
|
||||
}
|
||||
|
||||
function syncFinished() {
|
||||
sendMessageToAllClients({ type: 'sync-finished' });
|
||||
sendMessageToAllClients({ type: 'sync-finished', lastSyncedPush });
|
||||
}
|
||||
|
||||
function syncFailed() {
|
||||
sendMessageToAllClients({ type: 'sync-failed' });
|
||||
sendMessageToAllClients({ type: 'sync-failed', lastSyncedPush });
|
||||
}
|
||||
|
||||
function setLastSyncedPush(entityChangeId) {
|
||||
|
|
Loading…
Reference in a new issue