fix mini app bot father
This commit is contained in:
@@ -365,10 +365,17 @@ export function FamilyGroupView({ groupId }: { groupId: string }) {
|
||||
const loadMessages = useCallback(async (roomId: string) => {
|
||||
if (!token || isPinLocked) return;
|
||||
const room = rooms.find((item) => item.id === roomId);
|
||||
if (room?.type === 'BOT') return;
|
||||
const response = await fetchChatMessages(roomId, token);
|
||||
setMessages((response.messages ?? []).filter((message) => !message.isDeleted));
|
||||
}, [isPinLocked, rooms, token]);
|
||||
if (!room || room.type === 'BOT') return;
|
||||
try {
|
||||
const response = await fetchChatMessages(roomId, token);
|
||||
setMessages((response.messages ?? []).filter((message) => !message.isDeleted));
|
||||
} catch (error) {
|
||||
const message = getApiErrorMessage(error, 'Не удалось загрузить сообщения');
|
||||
if (message && !message.includes('Bot API')) {
|
||||
showToast(message);
|
||||
}
|
||||
}
|
||||
}, [isPinLocked, rooms, showToast, token]);
|
||||
|
||||
const loadPresence = useCallback(async () => {
|
||||
if (!token || isPinLocked) return;
|
||||
@@ -406,10 +413,11 @@ export function FamilyGroupView({ groupId }: { groupId: string }) {
|
||||
|
||||
useEffect(() => {
|
||||
if (!activeRoomId || activeRoomIsBot) return;
|
||||
if (!rooms.some((room) => room.id === activeRoomId)) return;
|
||||
void loadMessages(activeRoomId);
|
||||
setEditingMessageId(null);
|
||||
setDraft('');
|
||||
}, [activeRoomId, activeRoomIsBot, loadMessages]);
|
||||
}, [activeRoomId, activeRoomIsBot, loadMessages, rooms]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!activeRoomId || !token || !messages.length) return;
|
||||
|
||||
@@ -394,7 +394,10 @@ export function MiniFamilyChat() {
|
||||
exitSelectionMode();
|
||||
showToast(ids.length === 1 ? 'Сообщение удалено' : 'Сообщения удалены');
|
||||
} catch (error) {
|
||||
if (activeRoom) {
|
||||
if (view === 'bot' && activeBot) {
|
||||
const response = await fetchBotChatMessages(activeBot.botRef, token);
|
||||
setBotMessages(response.messages ?? []);
|
||||
} else if (activeRoom && activeRoom.type !== 'BOT') {
|
||||
const response = await fetchChatMessages(activeRoom.id, token);
|
||||
setMessages((response.messages ?? []).filter((message) => !message.isDeleted));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user