2019-02-15 14:52:21 +09:00
|
|
|
<template>
|
|
|
|
<x-column>
|
2019-02-18 11:13:56 +09:00
|
|
|
<template #header>
|
2019-02-15 14:52:21 +09:00
|
|
|
<fa icon="search"/><span>{{ q }}</span>
|
2019-02-18 09:48:00 +09:00
|
|
|
</template>
|
2019-02-15 14:52:21 +09:00
|
|
|
|
|
|
|
<div>
|
2019-02-18 09:17:55 +09:00
|
|
|
<x-notes ref="timeline" :make-promise="makePromise" @inited="() => $emit('loaded')"/>
|
2019-02-15 14:52:21 +09:00
|
|
|
</div>
|
|
|
|
</x-column>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import XColumn from './deck.column.vue';
|
|
|
|
import XNotes from './deck.notes.vue';
|
|
|
|
|
|
|
|
const limit = 20;
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
|
|
|
XColumn,
|
|
|
|
XNotes
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2019-02-18 09:17:55 +09:00
|
|
|
makePromise: cursor => this.$root.api('notes/search', {
|
|
|
|
limit: limit + 1,
|
|
|
|
offset: cursor ? cursor : undefined,
|
|
|
|
query: this.q
|
|
|
|
}).then(notes => {
|
|
|
|
if (notes.length == limit + 1) {
|
|
|
|
notes.pop();
|
|
|
|
return {
|
|
|
|
notes: notes,
|
|
|
|
cursor: cursor ? cursor + limit : limit
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return {
|
|
|
|
notes: notes,
|
|
|
|
cursor: null
|
|
|
|
};
|
|
|
|
}
|
|
|
|
})
|
2019-02-15 14:52:21 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
q(): string {
|
|
|
|
return this.$route.query.q;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
2019-02-18 09:17:55 +09:00
|
|
|
$route() {
|
|
|
|
this.$refs.timeline.reload();
|
2019-02-15 14:52:21 +09:00
|
|
|
}
|
2019-02-18 09:17:55 +09:00
|
|
|
},
|
2019-02-15 14:52:21 +09:00
|
|
|
});
|
|
|
|
</script>
|