[gnome-maps] application: Run contact geocode requests sequencially



commit 0d665a0a906670e0cb953a79b14a22d6d7a231a0
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Jun 4 21:16:05 2019 +0200

    application: Run contact geocode requests sequencially
    
    Fixes #183

 src/application.js | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 9cba29c..7f4cd6a 100644
--- a/src/application.js
+++ b/src/application.js
@@ -159,19 +159,29 @@ var Application = GObject.registerClass({
     }
 
     _addContacts() {
-        contactStore.get_contacts().forEach((contact) => {
-            contact.geocode(function() {
+        let contacts = contactStore.get_contacts();
+
+        this._addContactsRecursive(contacts, 0);
+    }
+
+    _addContactsRecursive(contacts, index) {
+        if (index < contacts.length) {
+            let contact = contacts[index];
+
+            contact.geocode(() => {
                 contact.get_places().forEach((p) => {
                     if (!p.location)
-                        return;
+                        return
 
                     Utils.debug('Adding contact address: ' + p.name);
                     let place = new ContactPlace.ContactPlace({ place: p,
                                                                 contact: contact });
                     placeStore.addPlace(place, PlaceStore.PlaceType.CONTACT);
                 });
+
+                this._addContactsRecursive(contacts, index + 1);
             });
-        });
+        }
     }
 
     _initPlaceStore() {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]