Sharkey/src/client/app/mobile/views/components/user-timeline.vue

48 lines
1,010 B
Vue
Raw Normal View History

2018-02-16 13:53:15 +02:00
<template>
<div class="mk-user-timeline">
<mk-notes ref="timeline" :make-promise="makePromise" @inited="() => $emit('loaded')">
2019-02-18 02:48:00 +02:00
<template v-slot:empty>
<fa :icon="['far', 'comments']"/>
{{ withMedia ? this.$t('no-notes-with-media') : this.$t('no-notes') }}
2019-02-18 02:48:00 +02:00
</template>
2018-04-07 20:30:37 +03:00
</mk-notes>
2018-02-16 13:53:15 +02:00
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
2018-02-23 01:07:30 +02:00
2018-04-26 05:46:42 +03:00
const fetchLimit = 10;
2018-02-23 01:07:30 +02:00
2018-02-16 13:53:15 +02:00
export default Vue.extend({
i18n: i18n('mobile/views/components/user-timeline.vue'),
2018-02-16 13:53:15 +02:00
props: ['user', 'withMedia'],
2018-05-03 17:32:46 +03:00
2018-02-16 13:53:15 +02:00
data() {
return {
makePromise: cursor => this.$root.api('users/notes', {
2018-03-29 08:48:47 +03:00
userId: this.user.id,
2018-04-26 05:46:42 +03:00
limit: fetchLimit + 1,
withFiles: this.withMedia,
untilId: cursor ? cursor : undefined
}).then(notes => {
2018-04-26 05:46:42 +03:00
if (notes.length == fetchLimit + 1) {
2018-04-07 20:30:37 +03:00
notes.pop();
return {
notes: notes,
cursor: notes[notes.length - 1].id
};
2018-02-23 01:07:30 +02:00
} else {
return {
notes: notes,
cursor: null
};
2018-02-23 01:07:30 +02:00
}
})
};
2018-02-16 13:53:15 +02:00
}
});
</script>