Browse Source

refactor(YooForum): change `getTopicList` function

dev
kdxcxs 4 years ago
parent
commit
a5e1d8b06a
  1. 14
      src/component/YooForum.js

14
src/component/YooForum.js

@ -14,6 +14,7 @@ export default class YooForum extends Component {
this.state = {
hint: '准备中',
topics: [],
fetchedListPage: 0,
};
this.initForum = this.initForum.bind(this);
this.getTopicList = this.getTopicList.bind(this);
@ -87,9 +88,7 @@ export default class YooForum extends Component {
'http://eol.ctbu.edu.cn/meol/jpk/course/layout/newpage/index.jsp?courseId=46445',
},
)
.then(() => {
this.getTopicList();
})
.then(this.getTopicList)
.catch(ShowErrorToast);
})
.catch(ShowErrorToast);
@ -101,7 +100,8 @@ export default class YooForum extends Component {
.catch(ShowErrorToast);
}
getTopicList(page = 1) {
getTopicList() {
const page = this.state.fetchedListPage + 1;
this.setState({hint: '获取数据中'});
gbkFetch(
'GET',
@ -128,7 +128,11 @@ export default class YooForum extends Component {
current.next().text(),
);
});
this.setState({topics: [...this.state.topics, ...newTopics], hint: ''});
this.setState({
topics: [...this.state.topics, ...newTopics],
hint: '',
fetchedListPage: page,
});
});
}

Loading…
Cancel
Save