diff options
| author | Soni L <EnderMoneyMod@gmail.com> | 2023-01-07 23:15:54 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-08 11:15:54 +0900 |
| commit | ecbefce2aaad4ab53861d50d93c4d339ad2597e4 (patch) | |
| tree | cd402e2c02fc324851fcf29ea92691f78de6264a | |
| parent | tweak (diff) | |
| download | misskey-ecbefce2aaad4ab53861d50d93c4d339ad2597e4.tar.gz misskey-ecbefce2aaad4ab53861d50d93c4d339ad2597e4.tar.bz2 misskey-ecbefce2aaad4ab53861d50d93c4d339ad2597e4.zip | |
Support remote objects in search (#9479)
* Support remote objects in search
Closes #9428
* Use account instead of localStorage
* Use useRouter instead of mainRouter
Co-authored-by: Chaos <chaoticryptidz@owo.monster>
| -rw-r--r-- | packages/frontend/src/pages/search.vue | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/frontend/src/pages/search.vue b/packages/frontend/src/pages/search.vue index c080b763bb..7918f9f577 100644 --- a/packages/frontend/src/pages/search.vue +++ b/packages/frontend/src/pages/search.vue @@ -12,12 +12,37 @@ import { computed } from 'vue'; import XNotes from '@/components/MkNotes.vue'; import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; +import * as os from '@/os'; +import { useRouter } from '@/router'; +import { $i } from '@/account'; + +const router = useRouter(); const props = defineProps<{ query: string; channel?: string; }>(); +const query = props.query; + +if ($i != null) { + if (query.startsWith('https://') || (query.startsWith('@') && !query.includes(' '))) { + const promise = os.api('ap/show', { + uri: props.query, + }); + + os.promiseDialog(promise, null, null, i18n.ts.fetchingAsApObject); + + const res = await promise; + + if (res.type === 'User') { + router.replace(`/@${res.object.username}@${res.object.host}`); + } else if (res.type === 'Note') { + router.replace(`/notes/${res.object.id}`); + } + } +} + const pagination = { endpoint: 'notes/search' as const, limit: 10, |