[polari] userTracker: Shut up a gjs warning



commit 7de0df832ba09a9ab3ddde59c112785f4b58d9f7
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Feb 16 23:22:45 2017 +0100

    userTracker: Shut up a gjs warning
    
    We were using "array[0]" as convenient shortcut for "first element
    or undefined if empty", but gjs starting printing a warning, so
    handle the case more explicitly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=778793

 src/userTracker.js |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/src/userTracker.js b/src/userTracker.js
index 34196e7..b484ee4 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -271,6 +271,8 @@ const UserTracker = new Lang.Class({
         let baseNick = Polari.util_get_basenick(nickName);
 
         let contacts = this._baseNickContacts.get(baseNick) || [];
+        if (!contacts.length)
+            return null;
 
         for (let i = 0; i < contacts.length; i++)
             if (contacts[i].alias == nickName)


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