You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main essence is that I'm getting duplicates of the same objects in this.data. One is actual (with new values), another is not. Changed object is placed at the end of array but old object not removed.
I found this code:
var oldIndex = -1;
if (oldVal) {
(function () {
var lookup = JSON.stringify(oldVal);
oldIndex = (0, _utilJs.findIndex)(_this4.value, function (x) {
return JSON.stringify(x) === lookup;
});
})();
}
In my case the returned value of comparison should be true but I got false coz the values was little bit different:
{"agents":[{"first_name":"Bilbo","last_name":"Baggins"}],"awaiting_from":"2016-11-22T13:07:00.395Z","customer":{"name":"1068916776508564q","tags":[{"id":48,"name":"customer_tag_3"},{"id":3,"name":"customer_tag_1"}]},"id":20232,"last_message":{"channel":{"name":"Facebook"},"created_at":"2016-11-14T11:01:50.758Z","id":1577651,"inbound":false,"text":"Hello, it's a custom message from Postman.","updated_at":"2016-11-14T11:01:51.531Z","user_id":4},"last_reminder":{"text":"test reminder","time":"2016-11-22T13:07:00.033Z"},"status":"new_message","tags":[{"id":5,"name":"conversation_tag_1"},{"id":6,"name":"conversation_tag_2"}]}
{"agents":[{"first_name":"Bilbo","last_name":"Baggins"}],"awaiting_from":"2016-11-22T13:07:00.395Z","customer":{"name":"1068916776508564q","tags":[{"id":48,"name":"customer_tag_3"},{"id":3,"name":"customer_tag_1"}]},"id":20232,"last_message":{"channel":{"name":"Facebook"},"created_at":"2016-11-14T11:01:50.758Z","id":1577651,"inbound":false,"text":"Hello, it's a custom message from Postman.","updated_at":"2016-11-14T11:01:51.531Z","user_id":4},"last_reminder":{"text":"test reminder","time":"2016-11-22T13:07:00.033Z","created_at":"2016-11-22T13:07:00.033Z"},"status":"new_message","tags":[{"id":5,"name":"conversation_tag_1"},{"id":6,"name":"conversation_tag_2"}]}
I have just changed QueryState.js to my specific case:
var oldIndex = -1;
if (oldVal) {
(function () {
// var lookup = JSON.stringify(oldVal);
oldIndex = (0, _utilJs.findIndex)(_this4.value, function (x) {
// return JSON.stringify(x) === lookup;
return x.id === oldVal.id;
});
})();
}
It works perfectly and faster (no performance tests though, lol) but requires presence of id (which should be an identificator). I think you could implement some feature to have (optionally) your identificator fieldname in observe to use this comparison without stringifying full object (and recommend to use it). Or, at least, to find how this bug appear and how it is possible to receive different objects in this case. Maybe it is fixable (I think so but too lazy to debug more).
The text was updated successfully, but these errors were encountered:
Interesting! I agree that using id is better, but I had assumed that oldVal would always be identical to the object that was already in the list, so just left the stringify in since there's no requirement that documents have unique keys.
I diffed the two objects you outputted, and the only difference was the second object defined last_reminder.created_at and the first object left it undefined. Is there anything different about the way you're populating that field than the others?
The main essence is that I'm getting duplicates of the same objects in
this.data
. One is actual (with new values), another is not. Changed object is placed at the end of array but old object not removed.I found this code:
In my case the returned value of comparison should be true but I got false coz the values was little bit different:
I have just changed
QueryState.js
to my specific case:It works perfectly and faster (no performance tests though, lol) but requires presence of
id
(which should be an identificator). I think you could implement some feature to have (optionally) your identificator fieldname inobserve
to use this comparison without stringifying full object (and recommend to use it). Or, at least, to find how this bug appear and how it is possible to receive different objects in this case. Maybe it is fixable (I think so but too lazy to debug more).The text was updated successfully, but these errors were encountered: