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