feat: allow searching for statuses (#632)

This commit is contained in:
Daniel Roe 2022-12-29 15:44:26 +01:00 committed by GitHub
parent 86a604ae9c
commit 12280afe70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 7 deletions

View file

@ -11,6 +11,7 @@ const onActivate = () => {
<CommonScrollIntoView as="RouterLink" :active="active" :to="result.to" py2 block px2 :aria-selected="active" :class="{ 'bg-active': active }" hover:bg-active @click="() => onActivate()">
<SearchHashtagInfo v-if="result.type === 'hashtag'" :hashtag="result.hashtag" />
<AccountInfo v-else-if="result.type === 'account'" :account="result.account" />
<StatusCard v-else-if="result.type === 'status'" :status="result.status" :actions="false" :show-reply-to="false" />
<div v-else-if="result.type === 'action'" text-center>
{{ result.action!.label }}
</div>

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
const query = ref('')
const { accounts, hashtags, loading } = useSearch(query)
const { accounts, hashtags, loading, statuses } = useSearch(query)
const index = ref(0)
const { t } = useI18n()
@ -13,8 +13,9 @@ const results = computed(() => {
return []
const results = [
...hashtags.value.slice(0, 3).map(hashtag => ({ type: 'hashtag', hashtag, to: `/tags/${hashtag.name}` })),
...accounts.value.map(account => ({ type: 'account', account, to: `/@${account.acct}` })),
...hashtags.value.slice(0, 3).map(hashtag => ({ type: 'hashtag', hashtag, to: getTagRoute(hashtag.name) })),
...accounts.value.map(account => ({ type: 'account', account, to: getAccountRoute(account) })),
...statuses.value.map(status => ({ type: 'status', status, to: getStatusRoute(status) })),
// Disable until search page is implemented
// {

View file

@ -1,10 +1,11 @@
import type { Account } from 'masto'
import type { Account, Status } from 'masto'
export interface SearchResult {
type: 'account' | 'hashtag' | 'action'
type: 'account' | 'hashtag' | 'action' | 'status'
to: string
label?: string
account?: Account
status?: Status
hashtag?: any
action?: {
label: string