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

62 lines
1.1 KiB
Vue
Raw Normal View History

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>
<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';
import i18n from '../../../i18n';
2018-02-17 01:19:16 +01:00
import Progress from '../../../common/scripts/loading';
2018-02-25 16:39:05 +01:00
const limit = 20;
2018-02-17 01:19:16 +01:00
export default Vue.extend({
i18n: i18n('mobile/views/pages/search.vue'),
2018-02-17 01:19:16 +01:00
data() {
return {
makePromise: cursor => this.$root.api('notes/search', {
limit: limit + 1,
untilId: cursor ? cursor : undefined,
query: 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 01:19:16 +01:00
};
},
2018-02-25 16:39:05 +01:00
watch: {
$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() {
2018-11-09 00:26:32 +01:00
document.title = `%i18n:@search%: ${this.q} | ${this.$root.instanceName}`;
2018-02-17 01:19:16 +01:00
},
methods: {
inited() {
Progress.done();
2018-02-25 16:39:05 +01:00
},
2018-02-17 01:19:16 +01:00
}
});
</script>