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

62 lines
1.1 KiB
Vue
Raw Normal View History

2018-02-17 09:19:16 +09:00
<template>
<mk-ui>
<span slot="header"><fa icon="search"/> {{ q }}</span>
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';
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 {
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
};
}
})
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() {
2018-11-09 08:26:32 +09:00
document.title = `%i18n:@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>