From 344799f3be95dded17bf068c42c0e8776e82aa3f Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 4 Nov 2015 18:47:52 +1300 Subject: Find exact record matches in store --- web/app/view/MapController.js | 8 ++++---- web/app/view/StateController.js | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'web/app/view') diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js index a9ef8cf44..7921de89f 100644 --- a/web/app/view/MapController.js +++ b/web/app/view/MapController.js @@ -52,9 +52,9 @@ Ext.define('Traccar.view.MapController', { var store = Ext.getStore('LatestPositions'); var deviceStore = Ext.getStore('Devices'); - var found = store.query('deviceId', data[i].deviceId); - if (found.getCount() > 0) { - found.first().set(data[i]); + var found = store.findRecord('deviceId', data[i].deviceId, 0, false, false, true); + if (found) { + found.set(data[i]); } else { store.add(Ext.create('Traccar.model.Position', data[i])); } @@ -67,7 +67,7 @@ Ext.define('Traccar.view.MapController', { if (data[i].deviceId in this.liveData) { this.liveData[data[i].deviceId].setGeometry(geometry); } else { - var name = deviceStore.query('id', data[i].deviceId).first().get('name'); + var name = deviceStore.findRecord('id', data[i].deviceId, 0, false, false, true).get('name'); var style = this.getMarkerStyle(Traccar.Style.mapLiveRadius, Traccar.Style.mapLiveColor, data[i].course, name); var marker = new ol.Feature({ diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js index 29f6a7c6d..819c203c4 100644 --- a/web/app/view/StateController.js +++ b/web/app/view/StateController.js @@ -116,9 +116,9 @@ Ext.define('Traccar.view.StateController', { selectDevice: function (device) { var found; this.deviceId = device.get('id'); - found = Ext.getStore('LatestPositions').query('deviceId', this.deviceId); - if (found.getCount() > 0) { - this.updatePosition(found.first()); + found = Ext.getStore('LatestPositions').findRecord('deviceId', this.deviceId, 0, false, false, true); + if (found) { + this.updatePosition(found); } else { Ext.getStore('Attributes').removeAll(); } -- cgit v1.2.3