2018-09-16 14:15:02 +00:00
|
|
|
<template>
|
2019-02-14 20:08:59 +00:00
|
|
|
<x-column>
|
2019-02-18 02:13:56 +00:00
|
|
|
<template #header>
|
2019-03-01 01:42:28 +00:00
|
|
|
<fa :icon="['fa', 'star']"/>{{ $t('@.favorites') }}
|
2019-02-18 00:48:00 +00:00
|
|
|
</template>
|
2019-02-14 20:08:59 +00:00
|
|
|
|
|
|
|
<div>
|
2019-02-18 00:17:55 +00:00
|
|
|
<x-notes ref="timeline" :make-promise="makePromise" @inited="() => $emit('loaded')"/>
|
2019-02-14 20:08:59 +00:00
|
|
|
</div>
|
|
|
|
</x-column>
|
2018-09-16 14:15:02 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2019-02-14 20:08:59 +00:00
|
|
|
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({
|
2019-02-14 20:08:59 +00:00
|
|
|
i18n: i18n(),
|
2018-09-16 14:15:02 +00:00
|
|
|
|
2019-02-14 20:08:59 +00:00
|
|
|
components: {
|
|
|
|
XColumn,
|
|
|
|
XNotes,
|
2018-09-16 14:15:02 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2019-02-18 00:17:55 +00:00
|
|
|
makePromise: cursor => this.$root.api('i/favorites', {
|
2018-09-16 14:15:02 +00:00
|
|
|
limit: fetchLimit + 1,
|
2019-02-18 00:17:55 +00:00
|
|
|
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();
|
2019-02-18 00:17:55 +00:00
|
|
|
return {
|
|
|
|
notes: notes,
|
|
|
|
cursor: notes[notes.length - 1].id
|
|
|
|
};
|
2018-09-16 14:15:02 +00:00
|
|
|
} else {
|
2019-02-18 00:17:55 +00:00
|
|
|
return {
|
|
|
|
notes: notes,
|
|
|
|
cursor: null
|
|
|
|
};
|
2018-09-16 14:15:02 +00:00
|
|
|
}
|
2019-02-18 00:17:55 +00:00
|
|
|
})
|
|
|
|
};
|
|
|
|
},
|
2018-10-19 17:49:39 +00:00
|
|
|
|
2019-02-18 00:17:55 +00:00
|
|
|
methods: {
|
2018-10-19 17:49:39 +00:00
|
|
|
focus() {
|
|
|
|
this.$refs.timeline.focus();
|
2018-10-21 07:18:02 +00:00
|
|
|
}
|
2018-09-16 14:15:02 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|