Browse Source

Load user list from cache

Sotaro KARASAWA 9 years ago
parent
commit
2c58bdc63c
2 changed files with 16 additions and 7 deletions
  1. 4 7
      resource/js/crowi.js
  2. 12 0
      resource/js/util/Crowi.js

+ 4 - 7
resource/js/crowi.js

@@ -601,13 +601,10 @@ $(function() {
     var $likerList = $("#liker-list");
     var likers = $likerList.data('likers');
     if (likers && likers.length > 0) {
-      // FIXME: user data cache
-      $.get('/_api/users.list', {user_ids: likers}, function(res) {
-        // ignore unless response has error
-        if (res.ok) {
-          AddToLikers(res.users);
-        }
-      });
+      var users = crowi.findUserByIds(likers.split(','));
+      if (users) {
+        AddToLikers(users);
+      }
     }
 
     function AddToLikers (users) {

+ 12 - 0
resource/js/util/Crowi.js

@@ -119,6 +119,18 @@ export default class Crowi {
     return null;
   }
 
+  findUserByIds(userIds) {
+    let users = [];
+    for (let userId of userIds) {
+      let user = this.findUserById(userId);
+      if (user) {
+        users.push(user);
+      }
+    }
+
+    return users;
+  }
+
   findUser(username) {
     if (this.userByName && this.userByName[username]) {
       return this.userByName[username];