Merge branch 'feature/typescript_backend_3' into feature/typescript_backend_4

This commit is contained in:
Elian Doran
2024-04-02 23:57:01 +03:00
49 changed files with 2356 additions and 5814 deletions

View File

@@ -29,11 +29,11 @@ let lastSyncedPush: number | null = null;
interface Message {
type: string;
data?: {
lastSyncedPush?: number,
lastSyncedPush?: number | null,
entityChanges?: any[],
safeImport?: boolean
},
lastSyncedPush?: number,
lastSyncedPush?: number | null,
progressCount?: number;
taskId?: string;
@@ -143,7 +143,7 @@ function fillInAdditionalProperties(entityChange: EntityChange) {
if (!entityChange.entity) {
entityChange.entity = sql.getRow(`SELECT * FROM notes WHERE noteId = ?`, [entityChange.entityId]);
if (entityChange.entity && entityChange.entity.isProtected) {
if (entityChange.entity?.isProtected) {
entityChange.entity.title = protectedSessionService.decryptString(entityChange.entity.title || "");
}
}
@@ -158,7 +158,7 @@ function fillInAdditionalProperties(entityChange: EntityChange) {
if (parentNote) {
for (const childBranch of parentNote.getChildBranches()) {
if (childBranch && childBranch.branchId) {
if (childBranch?.branchId) {
entityChange.positions[childBranch.branchId] = childBranch.notePosition;
}
}
@@ -223,7 +223,7 @@ function sendPing(client: WebSocket, entityChangeIds = []) {
sendMessage(client, {
type: 'frontend-update',
data: {
lastSyncedPush: lastSyncedPush || undefined,
lastSyncedPush,
entityChanges
}
});
@@ -238,19 +238,19 @@ function sendTransactionEntityChangesToAllClients() {
}
function syncPullInProgress() {
sendMessageToAllClients({ type: 'sync-pull-in-progress', lastSyncedPush: lastSyncedPush || undefined });
sendMessageToAllClients({ type: 'sync-pull-in-progress', lastSyncedPush });
}
function syncPushInProgress() {
sendMessageToAllClients({ type: 'sync-push-in-progress', lastSyncedPush: lastSyncedPush || undefined });
sendMessageToAllClients({ type: 'sync-push-in-progress', lastSyncedPush });
}
function syncFinished() {
sendMessageToAllClients({ type: 'sync-finished', lastSyncedPush: lastSyncedPush || undefined });
sendMessageToAllClients({ type: 'sync-finished', lastSyncedPush });
}
function syncFailed() {
sendMessageToAllClients({ type: 'sync-failed', lastSyncedPush: lastSyncedPush || undefined });
sendMessageToAllClients({ type: 'sync-failed', lastSyncedPush });
}
function reloadFrontend(reason: string) {