mirror of https://github.com/buster-so/buster.git
kill electric when finished streams
This commit is contained in:
parent
1a46465aaa
commit
dac18b5861
|
@ -13,6 +13,7 @@ const updateOperations: Array<`insert` | `update` | `delete`> = ['update'];
|
||||||
export const useTrackAndUpdateChatChanges = (
|
export const useTrackAndUpdateChatChanges = (
|
||||||
{
|
{
|
||||||
chatId,
|
chatId,
|
||||||
|
isStreamingMessage,
|
||||||
}: {
|
}: {
|
||||||
chatId: string | undefined;
|
chatId: string | undefined;
|
||||||
isStreamingMessage: boolean;
|
isStreamingMessage: boolean;
|
||||||
|
@ -23,7 +24,7 @@ export const useTrackAndUpdateChatChanges = (
|
||||||
const shape = useMemo(() => {
|
const shape = useMemo(() => {
|
||||||
return chatShape({ chatId: chatId || '' });
|
return chatShape({ chatId: chatId || '' });
|
||||||
}, [chatId]);
|
}, [chatId]);
|
||||||
const subscribe = !!chatId;
|
const subscribe = !!chatId && isStreamingMessage;
|
||||||
|
|
||||||
return useShapeStream(
|
return useShapeStream(
|
||||||
shape,
|
shape,
|
||||||
|
|
|
@ -33,6 +33,7 @@ export const useTrackAndUpdateMessageChanges = (
|
||||||
{
|
{
|
||||||
chatId,
|
chatId,
|
||||||
messageId,
|
messageId,
|
||||||
|
isStreamingMessage,
|
||||||
}: {
|
}: {
|
||||||
chatId: string | undefined;
|
chatId: string | undefined;
|
||||||
messageId: string;
|
messageId: string;
|
||||||
|
@ -45,7 +46,7 @@ export const useTrackAndUpdateMessageChanges = (
|
||||||
const getChatMemoized = useGetChatMemoized();
|
const getChatMemoized = useGetChatMemoized();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const subscribe = !!chatId && !!messageId && messageId !== 'undefined';
|
const subscribe = !!chatId && !!messageId && messageId !== 'undefined' && isStreamingMessage;
|
||||||
|
|
||||||
const shape = useMemo(() => {
|
const shape = useMemo(() => {
|
||||||
return messageShape({ chatId: chatId || '', messageId });
|
return messageShape({ chatId: chatId || '', messageId });
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { createDropdownItem } from '@/components/ui/dropdown';
|
||||||
import { ArrowRight, DuplicatePlus, Pencil, ShareRight, Star, Trash } from '@/components/ui/icons';
|
import { ArrowRight, DuplicatePlus, Pencil, ShareRight, Star, Trash } from '@/components/ui/icons';
|
||||||
import { Star as StarFilled } from '@/components/ui/icons/NucleoIconFilled';
|
import { Star as StarFilled } from '@/components/ui/icons/NucleoIconFilled';
|
||||||
import { useBusterNotifications } from '@/context/BusterNotifications';
|
import { useBusterNotifications } from '@/context/BusterNotifications';
|
||||||
|
import { ensureElementExists } from '@/lib/element';
|
||||||
import { getIsEffectiveOwner } from '@/lib/share';
|
import { getIsEffectiveOwner } from '@/lib/share';
|
||||||
import { timeout } from '@/lib/timeout';
|
import { timeout } from '@/lib/timeout';
|
||||||
import { getShareAssetConfig, ShareMenuContent } from '../ShareMenu';
|
import { getShareAssetConfig, ShareMenuContent } from '../ShareMenu';
|
||||||
|
@ -45,12 +46,18 @@ export const useRenameChatTitle = () => {
|
||||||
label: 'Rename',
|
label: 'Rename',
|
||||||
value: 'edit-chat-title',
|
value: 'edit-chat-title',
|
||||||
icon: <Pencil />,
|
icon: <Pencil />,
|
||||||
onClick: async () => {
|
onClick: async (e) => {
|
||||||
const input = document.getElementById(CHAT_HEADER_TITLE_ID) as HTMLInputElement;
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
const input = await ensureElementExists(
|
||||||
|
() => document.getElementById(CHAT_HEADER_TITLE_ID) as HTMLInputElement
|
||||||
|
);
|
||||||
if (input) {
|
if (input) {
|
||||||
await timeout(25);
|
// Focus first, then select after a small delay to ensure focus completes
|
||||||
input.focus();
|
input.focus();
|
||||||
input.select();
|
setTimeout(() => {
|
||||||
|
input.select(); //i think this is related to how the dropdown is closing and taking away focus
|
||||||
|
}, 200);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -11,7 +11,6 @@ import {
|
||||||
import { chatQueryKeys } from '@/api/query_keys/chat';
|
import { chatQueryKeys } from '@/api/query_keys/chat';
|
||||||
import { metricsQueryKeys } from '@/api/query_keys/metric';
|
import { metricsQueryKeys } from '@/api/query_keys/metric';
|
||||||
import { useBlackboxMessage } from '@/context/BlackBox/useBlackboxMessage';
|
import { useBlackboxMessage } from '@/context/BlackBox/useBlackboxMessage';
|
||||||
import { updateDocumentTitle } from '@/hooks/useDocumentTitle';
|
|
||||||
import { useMemoizedFn } from '@/hooks/useMemoizedFn';
|
import { useMemoizedFn } from '@/hooks/useMemoizedFn';
|
||||||
import { updateChatToIChat } from '@/lib/chat';
|
import { updateChatToIChat } from '@/lib/chat';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue