2018-02-17 01:19:16 +01:00
|
|
|
<template>
|
|
|
|
<mk-ui>
|
2019-02-18 03:13:56 +01:00
|
|
|
<template #header><fa icon="search"/> {{ q }}</template>
|
2018-07-04 14:23:50 +02:00
|
|
|
|
|
|
|
<main>
|
2019-02-18 01:17:55 +01:00
|
|
|
<mk-notes ref="timeline" :make-promise="makePromise" @inited="inited"/>
|
2018-02-17 01:19:16 +01:00
|
|
|
</main>
|
|
|
|
</mk-ui>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 19:44:35 +01:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-17 01:19:16 +01:00
|
|
|
import Progress from '../../../common/scripts/loading';
|
2019-04-25 00:46:39 +02:00
|
|
|
import { genSearchQuery } from '../../../common/scripts/gen-search-query';
|
2018-02-17 01:19:16 +01:00
|
|
|
|
2018-02-25 16:39:05 +01:00
|
|
|
const limit = 20;
|
2018-02-17 01:19:16 +01:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 19:44:35 +01:00
|
|
|
i18n: i18n('mobile/views/pages/search.vue'),
|
2018-02-17 01:19:16 +01:00
|
|
|
data() {
|
|
|
|
return {
|
2019-04-25 00:46:39 +02:00
|
|
|
makePromise: async cursor => this.$root.api('notes/search', {
|
2019-02-18 01:17:55 +01:00
|
|
|
limit: limit + 1,
|
2019-04-08 07:17:44 +02:00
|
|
|
untilId: cursor ? cursor : undefined,
|
2019-04-25 00:46:39 +02:00
|
|
|
...(await genSearchQuery(this, this.q))
|
2019-02-18 01:17:55 +01:00
|
|
|
}).then(notes => {
|
|
|
|
if (notes.length == limit + 1) {
|
|
|
|
notes.pop();
|
|
|
|
return {
|
|
|
|
notes: notes,
|
2019-04-08 07:17:44 +02:00
|
|
|
more: true
|
2019-02-18 01:17:55 +01:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return {
|
|
|
|
notes: notes,
|
2019-04-08 07:17:44 +02:00
|
|
|
more: false
|
2019-02-18 01:17:55 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
})
|
2018-02-17 01:19:16 +01:00
|
|
|
};
|
|
|
|
},
|
2018-02-25 16:39:05 +01:00
|
|
|
watch: {
|
2019-02-18 01:17:55 +01:00
|
|
|
$route() {
|
|
|
|
this.$refs.timeline.reload();
|
|
|
|
}
|
2018-02-25 16:39:05 +01:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
q(): string {
|
|
|
|
return this.$route.query.q;
|
|
|
|
}
|
|
|
|
},
|
2018-02-17 01:19:16 +01:00
|
|
|
mounted() {
|
2019-04-16 06:05:10 +02:00
|
|
|
document.title = `${this.$t('search')}: ${this.q} | ${this.$root.instanceName}`;
|
2018-02-17 01:19:16 +01:00
|
|
|
},
|
|
|
|
methods: {
|
2019-02-18 01:17:55 +01:00
|
|
|
inited() {
|
|
|
|
Progress.done();
|
2018-02-25 16:39:05 +01:00
|
|
|
},
|
2018-02-17 01:19:16 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|