Преглед изворни кода

API call uses Crowi.apiGet () instead of jQuery.ajax

okonomi пре 9 година
родитељ
комит
ffe9b77124
1 измењених фајлова са 8 додато и 6 уклоњено
  1. 8 6
      resource/js/components/SeenUserList.js

+ 8 - 6
resource/js/components/SeenUserList.js

@@ -7,6 +7,8 @@ export default class SeenUserList extends React.Component {
   constructor(props) {
   constructor(props) {
     super(props);
     super(props);
 
 
+    this.crowi = window.crowi; // FIXME
+
     this.state = {
     this.state = {
       seenUsers: [],
       seenUsers: [],
     };
     };
@@ -16,12 +18,12 @@ export default class SeenUserList extends React.Component {
     const seenUserIds = this.getSeenUserIds();
     const seenUserIds = this.getSeenUserIds();
     if (seenUserIds.length > 0) {
     if (seenUserIds.length > 0) {
       // FIXME: user data cache
       // FIXME: user data cache
-      $.get('/_api/users.list', {user_ids: seenUserIds.join(',')}, function(res) {
-        // ignore unless response has error
-        if (res.ok) {
-          this.setState({seenUsers: res.users});
-        }
-      }.bind(this));
+      this.crowi.apiGet('/users.list', {user_ids: seenUserIds.join(',')})
+      .then(res => {
+        this.setState({seenUsers: res.users});
+      }).catch(err => {
+        // do nothing
+      });
     }
     }
   }
   }