perf(api,frontend): index hot queries, paginate chats, fix realtime
This commit is contained in:
1 parent
9d767d2531
commit
525ce024bc
27 files changed
+831
-268
No files matched your search
@@ -16,6 +16,7 @@
|
||||
import Icon from "$lib/components/ui/Icon.svelte";
|
||||
import Spinner from "$lib/components/ui/Spinner.svelte";
|
||||
import { accounts } from "$lib/stores/accounts.svelte";
|
||||
import { createChatPicker } from "$lib/stores/chat-picker.svelte";
|
||||
import { chats } from "$lib/stores/chats.svelte";
|
||||
import { toasts } from "$lib/stores/toasts.svelte";
|
||||
|
||||
@@ -79,15 +80,25 @@
|
||||
(f) => !folderPolicies.some((p) => p.scope_id === f.folder_id)
|
||||
)
|
||||
);
|
||||
const picker = createChatPicker();
|
||||
const availableChats = $derived(
|
||||
chats.list
|
||||
.filter((c) => !chatPolicies.some((p) => p.scope_id === c.chat_id))
|
||||
.filter((c) =>
|
||||
(c.title ?? "").toLowerCase().includes(chatFilter.trim().toLowerCase())
|
||||
)
|
||||
.slice(0, 40)
|
||||
picker.results.filter(
|
||||
(c) => !chatPolicies.some((p) => p.scope_id === c.chat_id)
|
||||
)
|
||||
);
|
||||
|
||||
$effect(() => {
|
||||
picker.search(chatFilter);
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
for (const policy of chatPolicies) {
|
||||
if (policy.scope_id !== null) {
|
||||
chats.ensure(policy.scope_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function folderTitle(id: number | null): string {
|
||||
return folders.find((f) => f.folder_id === id)?.title ?? `Папка ${id}`;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user