Explorar o código

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

okonomi %!s(int64=9) %!d(string=hai) anos
pai
achega
ffe9b77124
Modificáronse 1 ficheiros con 8 adicións e 6 borrados
  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) {
     super(props);
 
+    this.crowi = window.crowi; // FIXME
+
     this.state = {
       seenUsers: [],
     };
@@ -16,12 +18,12 @@ export default class SeenUserList extends React.Component {
     const seenUserIds = this.getSeenUserIds();
     if (seenUserIds.length > 0) {
       // 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
+      });
     }
   }