mirror of
				https://github.com/ItzCrazyKns/Perplexica.git
				synced 2025-11-03 12:18:15 +00:00 
			
		
		
		
	feat(message-input): prevent message when loading
This commit is contained in:
		@@ -77,7 +77,7 @@ const Chat = ({
 | 
			
		||||
          className="bottom-24 lg:bottom-10 fixed z-40"
 | 
			
		||||
          style={{ width: dividerWidth }}
 | 
			
		||||
        >
 | 
			
		||||
          <MessageInput sendMessage={sendMessage} />
 | 
			
		||||
          <MessageInput loading={loading} sendMessage={sendMessage} />
 | 
			
		||||
        </div>
 | 
			
		||||
      )}
 | 
			
		||||
    </div>
 | 
			
		||||
 
 | 
			
		||||
@@ -6,8 +6,10 @@ import { Attach, CopilotToggle } from './MessageInputActions';
 | 
			
		||||
 | 
			
		||||
const MessageInput = ({
 | 
			
		||||
  sendMessage,
 | 
			
		||||
  loading,
 | 
			
		||||
}: {
 | 
			
		||||
  sendMessage: (message: string) => void;
 | 
			
		||||
  loading: boolean;
 | 
			
		||||
}) => {
 | 
			
		||||
  const [copilotEnabled, setCopilotEnabled] = useState(false);
 | 
			
		||||
  const [message, setMessage] = useState('');
 | 
			
		||||
@@ -25,12 +27,13 @@ const MessageInput = ({
 | 
			
		||||
  return (
 | 
			
		||||
    <form
 | 
			
		||||
      onSubmit={(e) => {
 | 
			
		||||
        if (loading) return;
 | 
			
		||||
        e.preventDefault();
 | 
			
		||||
        sendMessage(message);
 | 
			
		||||
        setMessage('');
 | 
			
		||||
      }}
 | 
			
		||||
      onKeyDown={(e) => {
 | 
			
		||||
        if (e.key === 'Enter' && !e.shiftKey) {
 | 
			
		||||
        if (e.key === 'Enter' && !e.shiftKey && !loading) {
 | 
			
		||||
          e.preventDefault();
 | 
			
		||||
          sendMessage(message);
 | 
			
		||||
          setMessage('');
 | 
			
		||||
@@ -58,7 +61,7 @@ const MessageInput = ({
 | 
			
		||||
            setCopilotEnabled={setCopilotEnabled}
 | 
			
		||||
          />
 | 
			
		||||
          <button
 | 
			
		||||
            disabled={message.trim().length === 0}
 | 
			
		||||
            disabled={message.trim().length === 0 || loading}
 | 
			
		||||
            className="bg-[#24A0ED] text-white disabled:text-white/50 hover:bg-opacity-85 transition duration-100 disabled:bg-[#ececec21] rounded-full p-2"
 | 
			
		||||
          >
 | 
			
		||||
            <ArrowUp className="bg-background" size={17} />
 | 
			
		||||
@@ -74,7 +77,7 @@ const MessageInput = ({
 | 
			
		||||
              setCopilotEnabled={setCopilotEnabled}
 | 
			
		||||
            />
 | 
			
		||||
            <button
 | 
			
		||||
              disabled={message.trim().length === 0}
 | 
			
		||||
              disabled={message.trim().length === 0 || loading}
 | 
			
		||||
              className="bg-[#24A0ED] text-white disabled:text-white/50 hover:bg-opacity-85 transition duration-100 disabled:bg-[#ececec21] rounded-full p-2"
 | 
			
		||||
            >
 | 
			
		||||
              <ArrowUp className="bg-background" size={17} />
 | 
			
		||||
 
 | 
			
		||||
@@ -168,7 +168,7 @@ const SettingsDialog = ({
 | 
			
		||||
                      <p className="text-white/70 text-sm">OpenAI API Key</p>
 | 
			
		||||
                      <input
 | 
			
		||||
                        type="text"
 | 
			
		||||
                        placeholder='OpenAI API Key'
 | 
			
		||||
                        placeholder="OpenAI API Key"
 | 
			
		||||
                        defaultValue={config.openeaiApiKey}
 | 
			
		||||
                        onChange={(e) =>
 | 
			
		||||
                          setConfig({
 | 
			
		||||
@@ -183,7 +183,7 @@ const SettingsDialog = ({
 | 
			
		||||
                      <p className="text-white/70 text-sm">Ollama API URL</p>
 | 
			
		||||
                      <input
 | 
			
		||||
                        type="text"
 | 
			
		||||
                        placeholder='Ollama API URL'
 | 
			
		||||
                        placeholder="Ollama API URL"
 | 
			
		||||
                        defaultValue={config.ollamaApiUrl}
 | 
			
		||||
                        onChange={(e) =>
 | 
			
		||||
                          setConfig({
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user