monkeeShark/src/client/app/mobile/views/pages/favorites.vue

87 lines
1.8 KiB
Vue
Raw Normal View History

2018-05-29 05:42:29 +00:00
<template>
<mk-ui>
<span slot="header"><span style="margin-right:4px;"><fa icon="star"/></span>{{ $t('title') }}</span>
2018-05-29 05:42:29 +00:00
<main>
2018-12-16 02:32:20 +00: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 16:20:26 +00:00
<ui-button v-if="existMore" @click="more">{{ $t('@.load-more') }}</ui-button>
2018-05-29 05:42:29 +00:00
</main>
</mk-ui>
</template>
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
2018-05-29 05:42:29 +00:00
import Progress from '../../../common/scripts/loading';
export default Vue.extend({
i18n: i18n('mobile/views/pages/favorites.vue'),
2018-05-29 05:42:29 +00:00
data() {
return {
fetching: true,
favorites: [],
existMore: false,
moreFetching: false
};
},
created() {
this.fetch();
},
mounted() {
2018-11-08 23:26:32 +00:00
document.title = `${this.$root.instanceName} | %i18n:@notifications%`;
2018-05-29 05:42:29 +00:00
},
methods: {
fetch() {
Progress.start();
this.fetching = true;
2018-11-08 23:13:34 +00:00
this.$root.api('i/favorites', {
2018-05-29 05:42:29 +00: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-08 23:13:34 +00:00
this.$root.api('i/favorites', {
2018-05-29 05:42:29 +00:00
limit: 11,
2018-07-30 05:46:11 +00:00
untilId: this.favorites[this.favorites.length - 1].id
2018-05-29 05:42:29 +00: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
2018-12-16 02:32:20 +00:00
> * > .post
2018-05-29 05:42:29 +00:00
margin-bottom 8px
@media (min-width 500px)
2018-12-16 02:32:20 +00:00
> * > .post
2018-05-29 05:42:29 +00:00
margin-bottom 16px
</style>