Skip to content

Commit c50edf5

Browse files
fix: Redux to update files properly after removing from UI (#414)
* fix: Redux to update files properly after removing from UI * fix: improve attachment handling and state updates in AttachmentComponent * fix: streamline attachment change detection logic in AttachmentComponent --------- Co-authored-by: Siva Rama Krishna <[email protected]> Co-authored-by: tumms2021389 <[email protected]>
1 parent c2d7943 commit c50edf5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/angular-sdk-components/src/lib/_components/widget/attachment/attachment.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,12 @@ export class AttachmentComponent implements OnInit, OnDestroy {
159159
const rawValue = this.pConn$.getComponentConfig().value;
160160
const isAttachmentAnnotationPresent = typeof rawValue === 'object' ? false : rawValue?.includes('@ATTACHMENT');
161161
const { attachments, isOldAttachment } = isAttachmentAnnotationPresent ? value : PCore.getAttachmentUtils().prepareAttachmentData(value);
162+
const isAttachmentsChanged = !PCore.isDeepEqual(this.attachments, attachments);
162163
this.isOldAttachment = isOldAttachment;
163164
this.attachments = attachments;
164165

165166
// update the attachments shown in the UI
166-
if (this.attachments.length) {
167+
if (isAttachmentsChanged) {
167168
this.updateAttachments();
168169
}
169170
}
@@ -421,6 +422,7 @@ export class AttachmentComponent implements OnInit, OnDestroy {
421422
fileResponses[index].value.thumbnail = localFile.props.thumbnail;
422423
localFile.inProgress = false;
423424
localFile.ID = fileResponses[index].value.ID;
425+
localFile.props.id = fileResponses[index].value.ID;
424426
localFile.props.meta = this.localizationService.getLocalizedText('Uploaded successfully');
425427
localFile.props.progress = 100;
426428
localFile.handle = fileResponses[index].value.ID;

0 commit comments

Comments
 (0)