import React from 'react'; import PropTypes from 'prop-types'; import loggerFactory from '@alias/logger'; import { withUnstatedContainers } from '../UnstatedUtils'; import AppContainer from '../../services/AppContainer'; import PageContainer from '../../services/PageContainer'; import { toastError } from '../../util/apiNotification'; import PaginationWrapper from '../PaginationWrapper'; import Page from '../PageList/Page'; const logger = loggerFactory('growi:MyBookmarkList'); class MyBookmarkList extends React.Component { constructor(props) { super(props); this.state = { pages: [], activePage: 1, totalPages: 0, pagingLimit: Infinity, }; this.handlePage = this.handlePage.bind(this); } componentWillMount() { this.getMyBookmarkList(1); } async handlePage(selectedPage) { await this.getMyBookmarkList(selectedPage); } async getMyBookmarkList(selectPageNumber) { const { appContainer, pageContainer } = this.props; const { pageId } = pageContainer.state; const userId = appContainer.currentUserId; /* TODO GW-3255 get config from customize settings */ const limit = appContainer.getConfig().recentCreatedLimit; const offset = (selectPageNumber - 1) * limit; /* /pages.myBookmarks is not exitst. TODO GW-3251 Create api v3 /pages.myBookmarks */ // This block is cited from MyDraftList /* await this.props.appContainer.apiGet('/pages.myBookmarks', { page_id: pageId, user: userId, limit, offset, }) .then((res) => { const totalPages = res.totalCount; const pages = res.pages; const activePage = selectPageNumber; this.setState({ pages, activePage, totalPages, pagingLimit: limit, }); }); */ try { await pageContainer.retrieveMyBookmarkList(pageId, userId, limit, offset); } catch (error) { logger.error('failed to fetch data', error); toastError(error, 'Error occurred in bookmark page list'); } } /** * generate Elements of Page * * @param {any} pages Array of pages Model Obj * */ generatePageList(pages) { /* TODO GW-3251 */ return pages.map(page => (