Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] handling error and not showing InputBox when not authenticated #107

Merged
merged 2 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/inappchat/helpers/sortMessagesByDate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default function messagesSortedByDate(messagesArray) {
return messagesArray.sort(function (a, b) {
return messagesArray?.sort(function (a, b) {
return a.ts < b.ts ? -1 : a.ts > b.ts ? 1 : 0;
});
};
22 changes: 13 additions & 9 deletions app/components/inappchat/inappchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ const InAppChat = ({ closeChat, cookies, rid }) => {

useEffect(() => {
const runRealtime = async (token, rid) => {
await rcClient.connect({ host: rcURL.host, useSsl });
await rcClient.resume({ token });
await rcClient.subscribe("stream-room-messages", rid);
rcClient.onMessage(() => {
// TODO: add the animate function here,
// and check if that corresponds to any of the emoji that we want to animate then animate()
getData();
});
try {
await rcClient.connect({ host: rcURL.host, useSsl });
await rcClient.resume({ token });
await rcClient.subscribe("stream-room-messages", rid);
rcClient.onMessage(() => {
// TODO: add the animate function here,
// and check if that corresponds to any of the emoji that we want to animate then animate()
getData();
});
} catch(err) {
console.log(err.message);
}
};
async function getData() {
const data = await getMessages(rid, cookies);
Expand Down Expand Up @@ -94,7 +98,7 @@ const InAppChat = ({ closeChat, cookies, rid }) => {
)}
</Box>
</div>
<InappchatTextInput sendMsg={sendMsg} />
{cookies.rc_token && cookies.rc_uid && <InappchatTextInput sendMsg={sendMsg} />}
</div>
);
};
Expand Down