Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update search.note.vue #58

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions packages/frontend/src/pages/search.note.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
</div>
</div>

<div v-if="lookedUpNote || lookedUpUser">
<header>{{ i18n.ts.lookup }}</header>
<MkNote v-if="lookedUpNote" :note="lookedUpNote"/>
<MkUserInfo v-if="lookedUpUser" :user="lookedUpUser"/>
</div>
<MkFoldableSection v-if="notePagination">
<template #header>{{ i18n.ts.searchResult }}</template>
<MkNotes :key="key" :pagination="notePagination"/>
Expand All @@ -43,6 +48,7 @@

<script lang="ts" setup>
import { ref } from 'vue';
import * as Misskey from 'misskey-js';
import MkNotes from '@/components/MkNotes.vue';
import MkInput from '@/components/MkInput.vue';
import MkButton from '@/components/MkButton.vue';
Expand All @@ -53,6 +59,8 @@
import MkFoldableSection from '@/components/MkFoldableSection.vue';
import MkFolder from '@/components/MkFolder.vue';
import { useRouter } from '@/router/supplier.js';
import MkNote from '@/components/MkNote.vue';
import MkUserInfo from '@/components/MkUserInfo.vue';

const router = useRouter();

Expand All @@ -62,6 +70,8 @@
const notePagination = ref();
const user = ref<any>(null);
const isLocalOnly = ref(false);
const lookedUpNote = ref<null | Misskey.entities.Note>(null);
const lookedUpUser = ref<null | Misskey.entities.UserDetailed>(null);

function selectUser() {
os.selectUser({ includeSelf: true }).then(_user => {
Expand All @@ -70,26 +80,23 @@
}

async function search() {
lookedUpNote.value = null;
lookedUpUser.value = null;
const query = searchQuery.value.toString().trim();

if (query == null || query === '') return;

// 照会
if (query.startsWith('https://')) {
const promise = misskeyApi('ap/show', {
misskeyApi('ap/show', {
uri: query,
});

os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject);

const res = await promise;

if (res.type === 'User') {
router.push(`/@${res.object.username}@${res.object.host}`);
} else if (res.type === 'Note') {
router.push(`/notes/${res.object.id}`);
}

return;
}).then(res => {
if (res.type === 'Note') {
lookedUpNote.value = res.object;
} else if (res.type === 'User') {
lookedUpUser.value = res.object;
}
})

Check failure on line 99 in packages/frontend/src/pages/search.note.vue

View workflow job for this annotation

GitHub Actions / lint (frontend)

Missing semicolon
}

notePagination.value = {
Expand Down
Loading