11<template >
22 <ul v-infinite-scroll =" load" class =" infinite-list flex-1" style =" overflow : auto " >
33 <li class =" flex text-4xl font-bold my-5 py-4" >Home</li >
4+ <li v-for =" note in notes" :key =" note.id" >
5+ <Note :note =" note" :character =" character" />
6+ </li >
47 <li v-for =" (_, index) in Array(5)" :key =" index" v-show =" loading" >
58 <el-skeleton animated >
69 <template #template >
1619 </template >
1720 </el-skeleton >
1821 </li >
19- <li v-for =" note in notes" :key =" note.id" >
20- <Note :note =" note" :character =" character" />
21- </li >
22- <li v-if =" !loading && notes.length === 0" >
22+ <li v-if =" !haveMore && notes.length === 0" >
2323 <p class =" text-center text-gray-500" >
2424 <span class =" align-middle" >No notes yet... Try to </span >
2525 <el-button class =" align-middle" text bg type =" primary" @click =" tweet" >sync a tweet</el-button >
@@ -39,7 +39,8 @@ const router = useRouter();
3939const store = useStore ();
4040
4141const notes = ref <TypeNote []>([]);
42- const loading = ref (true );
42+ const loading = ref (false );
43+ const haveMore = ref (true );
4344
4445if (store .state .settings .address ) {
4546 if (! store .state .characters ?.list .length ) {
@@ -52,10 +53,9 @@ if (store.state.settings.address) {
5253}
5354
5455let cursor: any ;
55- let first = true ;
5656const load = async () => {
57- if (cursor || first ) {
58- first = false ;
57+ if (! loading . value && haveMore . value ) {
58+ loading . value = true ;
5959 const result = await window .unidata .notes .get ({
6060 identity: store .state .settings .handle ! ,
6161 platform: ' Crossbell' ,
@@ -65,10 +65,18 @@ const load = async () => {
6565 applications: [' CrossSync' ],
6666 },
6767 }),
68- cursor ,
68+ ... ( cursor && { cursor }) ,
6969 });
70- notes .value = notes .value .concat (result ?.list || []);
71- cursor = result ?.cursor ;
70+ if (result ?.list && result .list .length > 0 ) {
71+ if (result ?.cursor ) {
72+ cursor = result .cursor ;
73+ } else {
74+ haveMore .value = false ;
75+ }
76+ notes .value = notes .value .concat (result .list );
77+ } else {
78+ haveMore .value = false ;
79+ }
7280 loading .value = false ;
7381 }
7482};
0 commit comments