feat(api,userbot,frontend): search peers without chats and start tracking them
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
import { formatPresence } from "$lib/format/presence";
|
||||
import { accounts } from "$lib/stores/accounts.svelte";
|
||||
import { chats } from "$lib/stores/chats.svelte";
|
||||
import { discover } from "$lib/stores/discover.svelte";
|
||||
import { events } from "$lib/stores/events.svelte";
|
||||
import { toasts } from "$lib/stores/toasts.svelte";
|
||||
import { ui } from "$lib/stores/ui.svelte";
|
||||
@@ -27,6 +28,7 @@
|
||||
|
||||
const isDm = $derived(chatId > 0);
|
||||
const chat = $derived(chats.byId(chatId));
|
||||
const discovered = $derived(discover.get(chatId));
|
||||
let peer = $state<PeerView | null>(null);
|
||||
let presence = $state<PresenceSample | null>(null);
|
||||
let backfilling = $state(false);
|
||||
@@ -46,6 +48,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
if (accounts.selectedId === null) {
|
||||
return;
|
||||
}
|
||||
discover.ensure(chatId).catch(() => undefined);
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (accounts.selectedId === null || !isDm) {
|
||||
peer = null;
|
||||
@@ -103,7 +112,9 @@
|
||||
});
|
||||
|
||||
const fallbackTitle = $derived(
|
||||
chat?.title ?? (isDm ? "Удалённый аккаунт" : `Chat ${chatId}`)
|
||||
chat?.title ??
|
||||
discovered?.title ??
|
||||
(isDm ? "Удалённый аккаунт" : `Chat ${chatId}`)
|
||||
);
|
||||
const title = $derived(isDm && peer ? peerName(peer) : fallbackTitle);
|
||||
const subtitle = $derived.by(() => {
|
||||
@@ -116,11 +127,16 @@
|
||||
}
|
||||
return peer?.phone ?? `ID ${chatId}`;
|
||||
}
|
||||
const count = chat?.message_count ?? 0;
|
||||
return count > 0 ? `${count} messages` : "group";
|
||||
const count = chat?.message_count ?? discovered?.message_count ?? 0;
|
||||
if (count > 0) {
|
||||
return `${count} messages`;
|
||||
}
|
||||
return discovered?.kind === "channel" ? "channel" : "group";
|
||||
});
|
||||
const avatarKind = $derived(isDm ? "peer" : "chat");
|
||||
const hasAvatar = $derived(chat?.has_avatar ?? Boolean(peer?.has_avatar));
|
||||
const hasAvatar = $derived(
|
||||
chat?.has_avatar ?? Boolean(peer?.has_avatar || discovered?.has_avatar)
|
||||
);
|
||||
</script>
|
||||
|
||||
<header class="chat-header">
|
||||
|
||||
Reference in New Issue
Block a user