fix(client): undefined entity in some cases

This commit is contained in:
Elian Doran 2025-01-16 18:36:23 +02:00
parent 1e182f5820
commit d684440c1f
No known key found for this signature in database
2 changed files with 14 additions and 8 deletions

View File

@ -1,12 +1,16 @@
import type { EntityRowNames } from "./services/load_results.js"; import type { EntityRowNames } from "./services/load_results.js";
interface Entity {
isDeleted?: boolean;
}
// TODO: Deduplicate with src/services/entity_changes_interface.ts // TODO: Deduplicate with src/services/entity_changes_interface.ts
export interface EntityChange { export interface EntityChange {
id?: number | null; id?: number | null;
noteId?: string; noteId?: string;
entityName: EntityRowNames; entityName: EntityRowNames;
entityId: string; entityId: string;
entity?: any; entity?: Entity;
positions?: Record<string, number>; positions?: Record<string, number>;
hash: string; hash: string;
utcDateChanged?: string; utcDateChanged?: string;

View File

@ -290,14 +290,16 @@ function processAttachment(loadResults: LoadResults, ec: EntityChange) {
return; return;
} }
if (attachment) { if (ec.entity) {
attachment.update(ec.entity as FAttachmentRow); if (attachment) {
} else { attachment.update(ec.entity as FAttachmentRow);
const attachmentRow = ec.entity as FAttachmentRow; } else {
const note = froca.notes[attachmentRow.ownerId]; const attachmentRow = ec.entity as FAttachmentRow;
const note = froca.notes[attachmentRow.ownerId];
if (note?.attachments) { if (note?.attachments) {
note.attachments.push(new FAttachment(froca, attachmentRow)); note.attachments.push(new FAttachment(froca, attachmentRow));
}
} }
} }