File tree Expand file tree Collapse file tree 3 files changed +26
-8
lines changed
Expand file tree Collapse file tree 3 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 77 @click =" onTweetClick"
88 />
99 </template >
10- <infinite-loading @infinite =" infiniteHandler" ref = " infiniteLoading " >
10+ <infinite-loading @infinite =" infiniteHandler" >
1111 <span slot =" no-more" />
1212 </infinite-loading >
1313 </div >
Original file line number Diff line number Diff line change @@ -51,7 +51,9 @@ export default {
5151
5252 async created () {
5353 try {
54- await this .fetchTweets ();
54+ await this .fetchTweets ({
55+ page: 1
56+ });
5557 } catch (error) {
5658 this .showErrorMessage (error .message );
5759 }
@@ -88,10 +90,10 @@ export default {
8890
8991 async infiniteHandler ($state ) {
9092 try {
91- const tweets = await this .fetchTweets ({ page: this .page });
93+ const tweets = await this .fetchTweets ({ page: this .page + 1 });
9294
9395 if (tweets .length ) {
94- this .page ++ ;
96+ this .page += 1 ;
9597 $state .loaded ();
9698 } else {
9799 $state .complete ();
Original file line number Diff line number Diff line change 99import { mapActions } from ' vuex' ;
1010import TweetPreviewList from ' @/components/common/TweetPreviewList.vue' ;
1111import NoContent from ' @/components/common/NoContent.vue' ;
12+ import showStatusToast from ' @/components/mixin/showStatusToast' ;
1213
1314export default {
1415 name: ' UserContainer' ,
1516
17+ mixins: [showStatusToast],
18+
1619 components: {
1720 TweetPreviewList,
1821 NoContent
@@ -23,6 +26,19 @@ export default {
2326 page: 1 ,
2427 }),
2528
29+ async created () {
30+ try {
31+ this .tweets = await this .fetchTweetsByUserId ({
32+ userId: this .$route .params .id ,
33+ params: {
34+ page: 1
35+ }
36+ });
37+ } catch (error) {
38+ this .showErrorMessage (error .message );
39+ }
40+ },
41+
2642 methods: {
2743 ... mapActions (' tweet' , [
2844 ' fetchTweetsByUserId' ,
@@ -32,20 +48,20 @@ export default {
3248 try {
3349 const tweets = await this .fetchTweetsByUserId ({
3450 userId: this .$route .params .id ,
35- params: {
36- page: this .page
51+ params: {
52+ page: this .page + 1
3753 }
3854 });
3955
4056 if (tweets .length ) {
4157 this .tweets .push (... tweets);
42- this .page ++ ;
58+ this .page += 1 ;
4359 $state .loaded ();
4460 } else {
4561 $state .complete ();
4662 }
4763 } catch (error) {
48- console . error (error);
64+ this . showErrorMessage (error . message );
4965 $state .loaded ();
5066 }
5167 },
You can’t perform that action at this time.
0 commit comments