misskey/src/client/app/mobile/views/pages/search.vue

63 lines
1.2 KiB
Vue
Raw Normal View History

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