misskey/src/client/app/desktop/views/deck/deck.favorites-column.vue

59 lines
1.0 KiB
Vue
Raw Normal View History

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