All files / src/stores hooks.ts

96.15% Statements 50/52
100% Branches 28/28
95% Functions 19/20
96.15% Lines 50/52

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80      1x     1x     1x 3x   1x 2x   1x   1x 2x   1x 14x   1x 12x   1x 12x   1x 1x   1x 1x     1x 3x 3x   1x 2x 2x   1x 2x 2x   1x 1x 1x   1x 1x 1x   1x 1x 1x   1x 7x 7x   1x 1x 1x   1x 4x 4x   1x 4x 4x   1x      
import { Message } from '@copilotkit/runtime-client-gql';
 
// Hooks
import { useChatStore } from '@/hooks/chat/useChatStore';
 
// Stores
import { chatStore } from './chat';
 
// States
export const useChatMessages = () =>
  useChatStore((state) => state.chatMessages);
 
export const useChatLoading = () =>
  useChatStore((state) => state.isChatLoading);
 
export const useChatFetched = () => useChatStore((state) => state.isFetched);
 
export const useChatInitialized = () =>
  useChatStore((state) => state.isChatInitialized);
 
export const useChatInputValue = () =>
  useChatStore((state) => state.inputValue);
 
export const useTextareaCursorPosition = () =>
  useChatStore((state) => state.textareaCursorPosition);
 
export const useTextareaScrollTop = () =>
  useChatStore((state) => state.textareaScrollTop);
 
export const useChatResetFlag = () =>
  useChatStore((state) => state.shouldResetChat);
 
export const useShouldLoadSuggestions = () =>
  useChatStore((state) => state.hasLoadedSuggestions);
 
// Actions
export const useSetChatMessages = (messages: Message[]) => {
  chatStore.setChatMessages(messages);
};
 
export const useSetChatLoading = (isLoading: boolean) => {
  chatStore.setChatLoading(isLoading);
};
 
export const useSetChatFetched = (isFetched: boolean) => {
  chatStore.setFetched(isFetched);
};
 
export const useSetChatInitialized = (isInitialized: boolean) => {
  chatStore.setChatInitialized(isInitialized);
};
 
export const useSetChatResetFlag = (shouldResetChat: boolean) => {
  chatStore.setChatResetFlag(shouldResetChat);
};
 
export const useResetChat = () => {
  chatStore.resetChat();
};
 
export const useSetChatInputValue = (value: string) => {
  chatStore.setInputValue(value);
};
 
export const useResetChatInput = () => {
  chatStore.resetChatInput();
};
 
export const useSetTextareaCursorPosition = (position: number) => {
  chatStore.setTextareaCursorPosition(position);
};
 
export const useSetTextareaScrollTop = (scrollTop: number) => {
  chatStore.setTextareaScrollTop(scrollTop);
};
 
export const useSetSuggestionsLoaded = (position: boolean) => {
  chatStore.setSuggestionsLoaded(position);
};