feat(backend,frontend): search everywhere in buttons, links and message data, a jump from search or an alert lights up the found words and buttons
This commit is contained in:
1 parent
acfa726e61
commit
d660079c02
21 files changed
+840
-76
No files matched your search
@@ -3,6 +3,7 @@
|
||||
import { visible } from "#lib/actions/visible.js";
|
||||
import ChatListItem from "#lib/components/ChatListItem.svelte";
|
||||
import DiscoverResultItem from "#lib/components/search/DiscoverResultItem.svelte";
|
||||
import SearchEverywhere from "#lib/components/search/SearchEverywhere.svelte";
|
||||
import SearchFilters from "#lib/components/search/SearchFilters.svelte";
|
||||
import SearchMessageItem from "#lib/components/search/SearchMessageItem.svelte";
|
||||
import Button from "#lib/components/ui/Button.svelte";
|
||||
@@ -14,7 +15,7 @@
|
||||
import { goto } from "$app/navigation";
|
||||
import { page } from "$app/state";
|
||||
|
||||
const { messages } = search;
|
||||
const { everywhere, messages } = search;
|
||||
let scroller = $state<HTMLDivElement | null>(null);
|
||||
|
||||
$effect(() => {
|
||||
@@ -25,12 +26,22 @@
|
||||
});
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
const key = search.everywhereRequest;
|
||||
untrack(() => search.syncEverywhere(key));
|
||||
});
|
||||
|
||||
const activeChatId = $derived(
|
||||
page.params.chatId ? Number(page.params.chatId) : null
|
||||
);
|
||||
const showChats = $derived(!search.filtered && search.chatHits.length > 0);
|
||||
const showPeers = $derived(!search.filtered && search.peerHits.length > 0);
|
||||
const hasMessages = $derived(messages.hits.length > 0);
|
||||
const needle = $derived(search.text.trim());
|
||||
const searchedAll = $derived(
|
||||
!(search.typing || messages.loading || messages.failed || messages.hasMore)
|
||||
);
|
||||
const deep = $derived(search.everywhereRequest !== "");
|
||||
const empty = $derived(
|
||||
!(
|
||||
search.typing ||
|
||||
@@ -38,7 +49,8 @@
|
||||
messages.failed ||
|
||||
showChats ||
|
||||
showPeers ||
|
||||
hasMessages
|
||||
hasMessages ||
|
||||
deep
|
||||
)
|
||||
);
|
||||
|
||||
@@ -74,8 +86,9 @@
|
||||
{#each messages.hits as hit (`${hit.chat_id}:${hit.message_id}`)}
|
||||
<SearchMessageItem
|
||||
{hit}
|
||||
href={search.hitHref(hit.chat_id, hit.message_id)}
|
||||
onclick={() => ui.requestJump(hit.chat_id, hit.message_id)}
|
||||
href={search.hitHref(hit.chat_id, hit.message_id, messages.terms)}
|
||||
onclick={() =>
|
||||
ui.requestJump(hit.chat_id, hit.message_id, messages.terms)}
|
||||
terms={messages.terms}
|
||||
/>
|
||||
{/each}
|
||||
@@ -98,6 +111,17 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<SearchEverywhere
|
||||
href={(hit) => search.hitHref(hit.chat_id, hit.message_id, [needle])}
|
||||
{needle}
|
||||
onopen={(hit) => ui.requestJump(hit.chat_id, hit.message_id, [needle])}
|
||||
onstart={() => search.searchEverywhere()}
|
||||
pager={everywhere}
|
||||
ready={searchedAll}
|
||||
shown={messages.hits}
|
||||
started={deep}
|
||||
/>
|
||||
|
||||
{#if empty}
|
||||
<EmptyState title={t("search.nothing")} />
|
||||
{/if}
|
||||
|
||||
Reference in new issue
Block a user