فهرست منبع

Use Crowi API method

okonomi 9 سال پیش
والد
کامیت
1296ed6e17
1فایلهای تغییر یافته به همراه6 افزوده شده و 8 حذف شده
  1. 6 8
      resource/js/components/BookmarkButton.js

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

@@ -38,16 +38,14 @@ export default class BookmarkButton extends React.Component {
     const pageId = this.props.pageId;
 
     if (!this.state.bookmarked) {
-      $.post('/_api/bookmarks.add', {_csrf: token, page_id: pageId}, (res) => {
-        if (res.ok && res.bookmark) {
-          this.markBookmarked();
-        }
+      this.props.crowi.apiPost('/bookmarks.add', {_csrf: token, page_id: pageId})
+      .then(res => {
+        this.markBookmarked();
       });
     } else {
-      $.post('/_api/bookmarks.remove', {_csrf: token, page_id: pageId}, (res) => {
-        if (res.ok) {
-          this.markUnBookmarked();
-        }
+      this.props.crowi.apiPost('/bookmarks.remove', {_csrf: token, page_id: pageId})
+      .then(res => {
+        this.markUnBookmarked();
       });
     }
   }