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