Skip to content

EspoCRM – Open Source CRM Application

fix list remove sync

Yuri Kuznetsov68f568949e61
diff --git a/client/src/model.js b/client/src/model.js
index 9557c975c6..fdb4675664 100644
--- a/client/src/model.js
+++ b/client/src/model.js
@@ -612,9 +612,11 @@ class Model {
const success = options.success;
+ const collection = this.collection;
+
const destroy = () => {
this.stopListening();
- this.trigger('destroy', this, this.collection, options);
+ this.trigger('destroy', this, collection, options);
};
options.success = response => {
@@ -633,8 +635,8 @@ class Model {
this.trigger('sync', this, response, syncOptions);
- if (this.collection) {
- this.collection.trigger('model-sync', this, syncOptions);
+ if (collection) {
+ collection.trigger('model-sync', this, syncOptions);
}
}
};
diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js
index 58693dbe10..027e4462f8 100644
--- a/client/src/views/record/list.js
+++ b/client/src/views/record/list.js
@@ -2178,6 +2178,10 @@ class ListRecordView extends View {
};
this.listenTo(collection, 'model-sync', (/** Model */m, /** Record */o) => {
+ if (o.action === 'destroy') {
+ this.removeRecordFromList(m.id);
+ }
+
const model = this.collection.get(m.id);
if (!model) {