This commit is contained in:
syuilo
2019-04-18 19:40:23 +09:00
parent cce768aaac
commit 7827aeb695
8 changed files with 128 additions and 71 deletions

View File

@@ -66,6 +66,7 @@ import i18n from '../../../i18n';
import { lang } from '../../../config';
import { faNewspaper, faHashtag, faHome, faColumns } from '@fortawesome/free-solid-svg-icons';
import { faMoon, faSun } from '@fortawesome/free-regular-svg-icons';
import { search } from '../../../common/scripts/search';
export default Vue.extend({
i18n: i18n('mobile/views/components/ui.nav.vue'),
@@ -133,29 +134,10 @@ export default Vue.extend({
}).then(async ({ canceled, result: query }) => {
if (canceled) return;
const q = query.trim();
if (q.startsWith('@')) {
this.$router.push(`/${q}`);
} else if (q.startsWith('#')) {
this.$router.push(`/tags/${encodeURIComponent(q.substr(1))}`);
} else if (q.startsWith('https://')) {
this.searching = true;
try {
const res = await this.$root.api('ap/show', {
uri: q
});
if (res.type == 'User') {
this.$router.push(`/@${res.object.username}@${res.object.host}`);
} else if (res.type == 'Note') {
this.$router.push(`/notes/${res.object.id}`);
}
} catch (e) {
// TODO
}
this.searching = true;
search(this, query).finally(() => {
this.searching = false;
} else {
this.$router.push(`/search?q=${encodeURIComponent(q)}`);
}
});
});
},

View File

@@ -54,6 +54,12 @@ export default Vue.extend({
},
created() {
this.$root.$on('warp', this.warp);
this.$once('hook:beforeDestroy', () => {
this.$root.$off('warp', this.warp);
this.connection.dispose();
});
const prepend = note => {
(this.$refs.timeline as any).prepend(note);
};
@@ -125,10 +131,6 @@ export default Vue.extend({
});
},
beforeDestroy() {
this.connection.dispose();
},
methods: {
focus() {
(this.$refs.timeline as any).focus();