monkeeShark/src/client/app/common/views/deck/deck.favorites-column.vue

59 lines
1 KiB
Vue
Raw Normal View History

2018-09-16 14:15:02 +00:00
<template>
<x-column>
2019-02-18 02:13:56 +00:00
<template #header>
<fa :icon="['fa', 'star']"/>{{ $t('@.favorites') }}
2019-02-18 00:48:00 +00:00
</template>
<div>
<x-notes ref="timeline" :make-promise="makePromise" @inited="() => $emit('loaded')"/>
</div>
</x-column>
2018-09-16 14:15:02 +00:00
</template>
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
import XColumn from './deck.column.vue';
2018-09-16 14:15:02 +00:00
import XNotes from './deck.notes.vue';
const fetchLimit = 10;
export default Vue.extend({
i18n: i18n(),
2018-09-16 14:15:02 +00:00
components: {
XColumn,
XNotes,
2018-09-16 14:15:02 +00:00
},
data() {
return {
makePromise: cursor => this.$root.api('i/favorites', {
2018-09-16 14:15:02 +00:00
limit: fetchLimit + 1,
untilId: cursor ? cursor : undefined,
}).then(notes => {
notes = notes.map(x => x.note);
2018-09-16 14:15:02 +00:00
if (notes.length == fetchLimit + 1) {
notes.pop();
return {
notes: notes,
cursor: notes[notes.length - 1].id
};
2018-09-16 14:15:02 +00:00
} else {
return {
notes: notes,
cursor: null
};
2018-09-16 14:15:02 +00:00
}
})
};
},
methods: {
focus() {
this.$refs.timeline.focus();
2018-10-21 07:18:02 +00:00
}
2018-09-16 14:15:02 +00:00
}
});
</script>