From db68a6adcd11dd36c3a6df72f409a0c1df1d0573 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 13 Dec 2016 16:52:18 -0800 Subject: [PATCH] fix broken search for myself --- interface/resources/qml/hifi/Pal.qml | 10 +++++----- scripts/system/pal.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/hifi/Pal.qml b/interface/resources/qml/hifi/Pal.qml index 01bff1125f..2e66da7905 100644 --- a/interface/resources/qml/hifi/Pal.qml +++ b/interface/resources/qml/hifi/Pal.qml @@ -41,9 +41,10 @@ Rectangle { property var userData: []; property var myData: ({displayName: "", userName: ""}); // valid dummy until set property bool iAmAdmin: false; - function findSessionIndex(sessionId) { // no findIndex in .qml - for (var i = 0; i < userData.length; i++) { - if (userData[i].sessionId === sessionId) { + function findSessionIndex(sessionId, optionalData) { // no findIndex in .qml + var i, data = optionalData || userData, length = data.length; + for (var i = 0; i < length; i++) { + if (data[i].sessionId === sessionId) { return i; } } @@ -53,7 +54,7 @@ Rectangle { switch (message.method) { case 'users': var data = message.params; - var myIndex = findSessionIndex(''); + var myIndex = findSessionIndex('', data); iAmAdmin = Users.canKick; myData = data[myIndex]; data.splice(myIndex, 1); @@ -105,7 +106,6 @@ Rectangle { } signal sendToScript(var message); function noticeSelection() { - console.log('selection changed'); var userIds = []; table.selection.forEach(function (userIndex) { userIds.push(userData[userIndex].sessionId); diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 426f2ad4a5..9f97676ce3 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -91,7 +91,7 @@ var AVATAR_OVERLAY = Script.resolvePath("assets/images/grabsprite-3.png"); function populateUserList() { var data = []; var counter = 1; - AvatarList.getAvatarIdentifiers().forEach(function (id) { + AvatarList.getAvatarIdentifiers().sort().forEach(function (id) { // sorting the identifiers is just an aid for debugging var avatar = AvatarList.getAvatar(id); data.push({ displayName: avatar.displayName || ('anonymous ' + counter++),