2018-02-16 12:53:15 +01:00
|
|
|
<template>
|
|
|
|
<div class="mk-user-timeline">
|
2019-02-20 16:30:53 +01:00
|
|
|
<mk-notes ref="timeline" :make-promise="makePromise" @inited="() => $emit('loaded')"/>
|
2018-02-16 12:53:15 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 19:44:35 +01:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-23 00:07:30 +01:00
|
|
|
|
2018-04-26 04:46:42 +02:00
|
|
|
const fetchLimit = 10;
|
2018-02-23 00:07:30 +01:00
|
|
|
|
2018-02-16 12:53:15 +01:00
|
|
|
export default Vue.extend({
|
2018-11-08 19:44:35 +01:00
|
|
|
i18n: i18n('mobile/views/components/user-timeline.vue'),
|
2019-02-18 01:17:55 +01:00
|
|
|
|
2018-02-16 12:53:15 +01:00
|
|
|
props: ['user', 'withMedia'],
|
2018-05-03 16:32:46 +02:00
|
|
|
|
2018-02-16 12:53:15 +01:00
|
|
|
data() {
|
|
|
|
return {
|
2019-04-18 15:00:11 +02:00
|
|
|
date: null,
|
2019-02-18 01:17:55 +01:00
|
|
|
makePromise: cursor => this.$root.api('users/notes', {
|
2018-03-29 07:48:47 +02:00
|
|
|
userId: this.user.id,
|
2018-04-26 04:46:42 +02:00
|
|
|
limit: fetchLimit + 1,
|
2019-02-18 01:17:55 +01:00
|
|
|
withFiles: this.withMedia,
|
2019-04-18 15:00:11 +02:00
|
|
|
untilDate: cursor ? undefined : (this.date ? this.date.getTime() : undefined),
|
2019-02-18 01:17:55 +01:00
|
|
|
untilId: cursor ? cursor : undefined
|
|
|
|
}).then(notes => {
|
2018-04-26 04:46:42 +02:00
|
|
|
if (notes.length == fetchLimit + 1) {
|
2018-04-07 19:30:37 +02:00
|
|
|
notes.pop();
|
2019-02-18 01:17:55 +01:00
|
|
|
return {
|
|
|
|
notes: notes,
|
2019-04-08 07:17:44 +02:00
|
|
|
more: true
|
2019-02-18 01:17:55 +01:00
|
|
|
};
|
2018-02-23 00:07:30 +01:00
|
|
|
} else {
|
2019-02-18 01:17:55 +01:00
|
|
|
return {
|
|
|
|
notes: notes,
|
2019-04-08 07:17:44 +02:00
|
|
|
more: false
|
2019-02-18 01:17:55 +01:00
|
|
|
};
|
2018-02-23 00:07:30 +01:00
|
|
|
}
|
2019-02-18 01:17:55 +01:00
|
|
|
})
|
|
|
|
};
|
2019-04-18 15:00:11 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.$root.$on('warp', this.warp);
|
|
|
|
this.$once('hook:beforeDestroy', () => {
|
|
|
|
this.$root.$off('warp', this.warp);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
warp(date) {
|
|
|
|
this.date = date;
|
|
|
|
(this.$refs.timeline as any).reload();
|
|
|
|
}
|
2018-02-16 12:53:15 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|