Skip to content

Commit

Permalink
Revert "Revert "Pushing streaming to Prod"" (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-s19 authored Jan 31, 2024
1 parent 50f13dc commit 34228b4
Show file tree
Hide file tree
Showing 15 changed files with 507 additions and 227 deletions.
1 change: 1 addition & 0 deletions apps/amakrushi/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"message.no_signal":"No signal. \nPlease check your internet connection",
"message.click_to_type": "Click here to type",
"message.downloading": "Downloading...",
"message.download_audio": "Loading Audio",
"message.no_link": "Something went wrong, please try later.",
"message.sharing": "Sharing...",
"message.no_history":"Your Chat History with AI will come here",
Expand Down
1 change: 1 addition & 0 deletions apps/amakrushi/lang/or.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"message.no_signal":"ସିଗ୍ନାଲ ନାହିଁ। \nଦୟାକରି ଆପଣଙ୍କ ଇଣ୍ଟରନେଟ ସଂଯୋଗ କୁ ଚେକ୍ କରନ୍ତ",
"message.click_to_type": "ଟାଇପ୍ କରିବାକୁ ଏଠାରେ କ୍ଲିକ୍ କରନ୍ତୁ",
"message.downloading": "ଡାଉନଲୋଡ୍ ହେଉଛି ....",
"message.download_audio": "ଅଡିଓ ଲୋଡିଂ କରୁଛି |",
"message.no_link": "କିଛି ଭୁଲ ହୋଇଗଲା, ଦୟାକରି ପରେ ଚେଷ୍ଟା କରନ୍ତୁ|",
"message.sharing": "ସେୟାରିଂ ....",
"message.no_history":"AI ସହିତ ଆପଣଙ୍କର ଚାଟ୍ ଇତିହାସ ଏଠାକୁ ଆସିବ |",
Expand Down
10 changes: 5 additions & 5 deletions apps/amakrushi/src/components/ChatWindow/ChatUiWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ const ChatUiWindow: React.FC = () => {
reaction: item.reaction,
msgId: item.id,
messageId: item.id,
audio_url: item.audioURL
audio_url: item.audioURL,
isEnd: true,
},
].filter(Boolean)
);
Expand Down Expand Up @@ -131,7 +132,7 @@ const ChatUiWindow: React.FC = () => {
);
console.log('fghj:', { messages: context?.messages });
const msgToRender = useMemo(() => {
return context?.isMsgReceiving
return context?.loading
? [
...normalizeMsgs,
{
Expand All @@ -141,7 +142,7 @@ const ChatUiWindow: React.FC = () => {
},
]
: normalizeMsgs;
}, [context?.isMsgReceiving, normalizeMsgs]);
}, [context?.loading, normalizeMsgs]);

console.log('debug:', { msgToRender });

Expand Down Expand Up @@ -242,7 +243,7 @@ const ChatUiWindow: React.FC = () => {
<Chat
btnColor="var(--secondarygreen)"
background="var(--bg-color)"
disableSend={context?.loading}
disableSend={context?.isMsgReceiving}
translation={t}
showTransliteration={!(localStorage.getItem('locale') === 'en')}
//@ts-ignore
Expand All @@ -253,7 +254,6 @@ const ChatUiWindow: React.FC = () => {
<ChatMessageItem
key={props}
message={props}
currentUser={context?.currentUser}
onSend={handleSend}
/>
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/amakrushi/src/components/NavBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function NavBar() {
);

const newChatHandler = useCallback(() => {
if (context?.loading) {
if (context?.isMsgReceiving) {
toast.error(`${t('error.wait_new_chat')}`);
return;
}
Expand Down
16 changes: 16 additions & 0 deletions apps/amakrushi/src/components/Sidemenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useCookies } from 'react-cookie';
import router from 'next/router';
import { logEvent } from 'firebase/analytics';
import { analytics } from '../../utils/firebase';
import toast from 'react-hot-toast';

export const Sidemenu = () => {
const t = useLocalization();
Expand Down Expand Up @@ -121,6 +122,11 @@ export const Sidemenu = () => {
<div
className={styles.user}
onClick={() => {
if (context?.isMsgReceiving) {
toast.error(`${t('error.wait_new_chat')}`);
onClose();
return;
}
router.push('/history');
onClose();
}}>
Expand All @@ -137,6 +143,11 @@ export const Sidemenu = () => {
<div
className={styles.user}
onClick={() => {
if (context?.isMsgReceiving) {
toast.error(`${t('error.wait_new_chat')}`);
onClose();
return;
}
router.push('/faq');
onClose();
}}>
Expand All @@ -153,6 +164,11 @@ export const Sidemenu = () => {
<div
className={styles.user}
onClick={() => {
if (context?.isMsgReceiving) {
toast.error(`${t('error.wait_new_chat')}`);
onClose();
return;
}
router.push('/feedback');
onClose();
}}>
Expand Down
13 changes: 13 additions & 0 deletions apps/amakrushi/src/components/blinking-spinner/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0; }
}

.spinner {
display: inline-block;
height: 15px;
width: 1px;
background-color: var(--secondarygreen);
/* border-radius: 50%; */
animation: blink .5s infinite;
}
10 changes: 10 additions & 0 deletions apps/amakrushi/src/components/blinking-spinner/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import styles from './index.module.css';

const BlinkingSpinner = () => {
return (
<p className={styles.spinner}></p>
);
}

export default BlinkingSpinner;
Loading

0 comments on commit 34228b4

Please sign in to comment.