2018-04-19 22:31:43 -06:00
|
|
|
<template>
|
|
|
|
<mk-ui>
|
|
|
|
<main v-if="!fetching">
|
|
|
|
<template v-for="favorite in favorites">
|
2018-05-28 23:22:15 -06:00
|
|
|
<mk-note-detail class="post" :note="favorite.note" :key="favorite.note.id"/>
|
2018-04-19 22:31:43 -06:00
|
|
|
</template>
|
2018-05-19 15:36:26 -06:00
|
|
|
<a v-if="existMore" @click="more">%i18n:@more%</a>
|
2018-04-19 22:31:43 -06:00
|
|
|
</main>
|
|
|
|
</mk-ui>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import Progress from '../../../common/scripts/loading';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: true,
|
|
|
|
favorites: [],
|
|
|
|
existMore: false,
|
|
|
|
moreFetching: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
|
|
|
Progress.start();
|
|
|
|
this.fetching = true;
|
|
|
|
|
|
|
|
(this as any).api('i/favorites', {
|
|
|
|
limit: 11
|
|
|
|
}).then(favorites => {
|
|
|
|
if (favorites.length == 11) {
|
|
|
|
this.existMore = true;
|
|
|
|
favorites.pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.favorites = favorites;
|
|
|
|
this.fetching = false;
|
|
|
|
|
|
|
|
Progress.done();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
more() {
|
|
|
|
this.moreFetching = true;
|
|
|
|
(this as any).api('i/favorites', {
|
|
|
|
limit: 11,
|
2018-07-29 15:20:06 -06:00
|
|
|
maxId: this.favorites[this.favorites.length - 1].note.id
|
2018-04-19 22:31:43 -06:00
|
|
|
}).then(favorites => {
|
|
|
|
if (favorites.length == 11) {
|
|
|
|
this.existMore = true;
|
|
|
|
favorites.pop();
|
|
|
|
} else {
|
|
|
|
this.existMore = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.favorites = this.favorites.concat(favorites);
|
|
|
|
this.moreFetching = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
|
|
|
main
|
|
|
|
margin 0 auto
|
|
|
|
padding 16px
|
|
|
|
max-width 700px
|
2018-05-28 23:22:15 -06:00
|
|
|
|
|
|
|
> .post
|
|
|
|
margin-bottom 16px
|
2018-04-19 22:31:43 -06:00
|
|
|
</style>
|