fix: inbox/messages/ new chat self-select (#577)
This commit is contained in:
1 parent
7fc3995956
commit
e3aab10cd0
2 files changed
+18
-8
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { profile } from '$lib/auth.svelte'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
import type { ListingType, Person } from 'lemmy-js-client'
|
import type { ListingType, Person } from 'lemmy-js-client'
|
||||||
@@ -12,6 +13,7 @@
|
|||||||
instance?: string | undefined
|
instance?: string | undefined
|
||||||
listing_type?: ListingType
|
listing_type?: ListingType
|
||||||
showWhenEmpty?: boolean
|
showWhenEmpty?: boolean
|
||||||
|
hideOwnUser?: boolean
|
||||||
onselect?: (e: Person) => void
|
onselect?: (e: Person) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,6 +22,7 @@
|
|||||||
instance = undefined,
|
instance = undefined,
|
||||||
listing_type = 'Subscribed',
|
listing_type = 'Subscribed',
|
||||||
showWhenEmpty = false,
|
showWhenEmpty = false,
|
||||||
|
hideOwnUser = false,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
@@ -28,15 +31,21 @@
|
|||||||
|
|
||||||
<Search
|
<Search
|
||||||
search={async q => {
|
search={async q => {
|
||||||
const results = await getClient(instance).search({
|
const users = (
|
||||||
q: q || ' ',
|
await getClient(instance).search({
|
||||||
type_: 'Users',
|
q: q || ' ',
|
||||||
limit: 20,
|
type_: 'Users',
|
||||||
listing_type: listing_type,
|
limit: 20,
|
||||||
sort: 'TopAll',
|
listing_type: listing_type,
|
||||||
})
|
sort: 'TopAll',
|
||||||
|
})
|
||||||
|
).users.map(c => c.person)
|
||||||
|
|
||||||
return results.users.map(c => c.person)
|
if (hideOwnUser) {
|
||||||
|
const myself = profile.data.user?.local_user_view.person.id
|
||||||
|
return users.filter(c => c.id != myself)
|
||||||
|
}
|
||||||
|
return users
|
||||||
}}
|
}}
|
||||||
extractName={c => `${c.name}@${new URL(c.actor_id).hostname}`}
|
extractName={c => `${c.name}@${new URL(c.actor_id).hostname}`}
|
||||||
bind:query={q}
|
bind:query={q}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
<Modal bind:open={searchModal.open} title={$t('routes.inbox.messages.start')}>
|
<Modal bind:open={searchModal.open} title={$t('routes.inbox.messages.start')}>
|
||||||
<UserAutocomplete
|
<UserAutocomplete
|
||||||
listing_type="All"
|
listing_type="All"
|
||||||
|
hideOwnUser={true}
|
||||||
onselect={u =>
|
onselect={u =>
|
||||||
goto(
|
goto(
|
||||||
resolveRoute('/inbox/messages/[user_id]', { user_id: u.id.toString() }),
|
resolveRoute('/inbox/messages/[user_id]', { user_id: u.id.toString() }),
|
||||||
|
|||||||
Reference in new issue
Block a user