Skip to content

Build your personal knowledge base with Trilium Notes

server-ts: Fix undefined in task_context

Elian Doran040ed39a4e14
diff --git a/src/services/task_context.ts b/src/services/task_context.ts
index 78ab6b10c4..7a16a26456 100644
--- a/src/services/task_context.ts
+++ b/src/services/task_context.ts
@@ -49,7 +49,7 @@ class TaskContext {
type: 'taskProgressCount',
taskId: this.taskId,
taskType: this.taskType,
- data: this.data || undefined,
+ data: this.data,
progressCount: this.progressCount
});
}
@@ -60,7 +60,7 @@ class TaskContext {
type: 'taskError',
taskId: this.taskId,
taskType: this.taskType,
- data: this.data || undefined,
+ data: this.data,
message: message
});
}
@@ -70,7 +70,7 @@ class TaskContext {
type: 'taskSucceeded',
taskId: this.taskId,
taskType: this.taskType,
- data: this.data || undefined,
+ data: this.data,
result: result
});
}
diff --git a/src/services/ws.ts b/src/services/ws.ts
index 575b6456b7..87caddcbaf 100644
--- a/src/services/ws.ts
+++ b/src/services/ws.ts
@@ -31,7 +31,7 @@ interface Message {
data?: {
lastSyncedPush?: number | null,
entityChanges?: any[]
- },
+ } | null,
lastSyncedPush?: number | null,
progressCount?: number;
@@ -142,7 +142,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 || "");
}
}
@@ -157,7 +157,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;
}
}