2018-04-20 06:31:43 +02:00
|
|
|
<template>
|
|
|
|
<mk-ui>
|
|
|
|
<main v-if="!fetching">
|
2018-12-16 03:32:20 +01:00
|
|
|
<sequential-entrance animation="entranceFromTop" delay="25">
|
|
|
|
<template v-for="favorite in favorites">
|
|
|
|
<mk-note-detail class="post" :note="favorite.note" :key="favorite.note.id"/>
|
|
|
|
</template>
|
|
|
|
</sequential-entrance>
|
2018-11-11 17:20:26 +01:00
|
|
|
<div class="more" v-if="existMore">
|
|
|
|
<ui-button inline @click="more">{{ $t('@.load-more') }}</ui-button>
|
|
|
|
</div>
|
2018-04-20 06:31:43 +02:00
|
|
|
</main>
|
|
|
|
</mk-ui>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 19:44:35 +01:00
|
|
|
import i18n from '../../../i18n';
|
2018-04-20 06:31:43 +02:00
|
|
|
import Progress from '../../../common/scripts/loading';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 19:44:35 +01:00
|
|
|
i18n: i18n('.vue'),
|
2018-04-20 06:31:43 +02:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: true,
|
|
|
|
favorites: [],
|
|
|
|
existMore: false,
|
|
|
|
moreFetching: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
|
|
|
Progress.start();
|
|
|
|
this.fetching = true;
|
|
|
|
|
2018-11-09 00:13:34 +01:00
|
|
|
this.$root.api('i/favorites', {
|
2018-04-20 06:31:43 +02:00
|
|
|
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;
|
2018-11-09 00:13:34 +01:00
|
|
|
this.$root.api('i/favorites', {
|
2018-04-20 06:31:43 +02:00
|
|
|
limit: 11,
|
2018-07-30 07:46:11 +02:00
|
|
|
untilId: this.favorites[this.favorites.length - 1].id
|
2018-04-20 06:31:43 +02: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-29 07:22:15 +02:00
|
|
|
|
2018-12-16 03:32:20 +01:00
|
|
|
> * > .post
|
2018-05-29 07:22:15 +02:00
|
|
|
margin-bottom 16px
|
2018-11-11 17:20:26 +01:00
|
|
|
|
|
|
|
> .more
|
|
|
|
margin 32px 16px 16px 16px
|
|
|
|
text-align center
|
|
|
|
|
2018-04-20 06:31:43 +02:00
|
|
|
</style>
|