2018-02-17 01:19:16 +01:00
|
|
|
<template>
|
|
|
|
<mk-ui>
|
2019-02-18 01:48:00 +01:00
|
|
|
<template v-slot: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';
|
|
|
|
|
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-02-18 01:17:55 +01:00
|
|
|
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 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() {
|
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: {
|
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>
|