Skip to content

Commit

Permalink
fix: add text to global state
Browse files Browse the repository at this point in the history
  • Loading branch information
danny-avila committed Mar 29, 2023
1 parent 55fce2d commit 3a51b54
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions client/src/components/Input/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import BingStyles from './BingStyles';
import ModelMenu from './Models/ModelMenu';
import Footer from './Footer';
import TextareaAutosize from 'react-textarea-autosize';
import createPayload from '~/utils/createPayload';
import RegenerateIcon from '../svg/RegenerateIcon';
import StopGeneratingIcon from '../svg/StopGeneratingIcon';
import { useMessageHandler } from '../../utils/handleSubmit';
Expand All @@ -20,13 +19,14 @@ export default function TextChat({ isSearchView = false }) {
const conversation = useRecoilValue(store.conversation);
const latestMessage = useRecoilValue(store.latestMessage);
const messages = useRecoilValue(store.messages);
const [text, setText] = useRecoilState(store.text);
// const [text, setText] = useState('');

const isSubmitting = useRecoilValue(store.isSubmitting);

// TODO: do we need this?
const disabled = false;

const [text, setText] = useState('');
const { ask, regenerate, stopGenerating } = useMessageHandler();

const bingStylesRef = useRef(null);
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/ui/Landing.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { useRecoilValue } from 'recoil';
import { useRecoilValue, useSetRecoilState } from 'recoil';
import useDocumentTitle from '~/hooks/useDocumentTitle';
import Templates from '../Prompts/Templates';
import SunIcon from '../svg/SunIcon';
Expand All @@ -11,6 +11,7 @@ import store from '~/store';

export default function Landing() {
const [showingTemplates, setShowingTemplates] = useState(false);
const setText = useSetRecoilState(store.text);
const conversation = useRecoilValue(store.conversation);
const { title = 'New Chat' } = conversation || {};

Expand All @@ -20,7 +21,7 @@ export default function Landing() {
e.preventDefault();
const { innerText } = e.target;
const quote = innerText.split('"')[1].trim();
// dispatch(setText(quote));
setText(quote);
};

const showTemplates = e => {
Expand Down
2 changes: 2 additions & 0 deletions client/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import conversation from './conversation';
import conversations from './conversations';
import models from './models';
import user from './user';
import text from './text';
import submission from './submission';
import search from './search';

Expand All @@ -10,6 +11,7 @@ export default {
...conversations,
...models,
...user,
text,
...submission,
...search
};
8 changes: 8 additions & 0 deletions client/src/store/text.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { atom } from 'recoil';

const text = atom({
key: 'text',
default: ''
});

export default text;
15 changes: 4 additions & 11 deletions client/src/store/user.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import React from "react";
import {
RecoilRoot,
atom,
selector,
useRecoilState,
useRecoilValue,
} from "recoil";
import { atom } from 'recoil';

const user = atom({
key: "user",
default: null,
key: 'user',
default: null
});

export default {
user,
user
};

0 comments on commit 3a51b54

Please sign in to comment.