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