From 8e1e281d214496c20f051f72da4a1274f4b96411 Mon Sep 17 00:00:00 2001 From: Nuwan Chathuranga Date: Thu, 7 Oct 2021 19:30:08 +0530 Subject: [PATCH] ability to reply for text message notifications --- .../components/notification/JKTextMessageNotification.js | 3 ++- jam-ui/src/components/page/JKPerson.js | 4 ++-- jam-ui/src/components/profile/JKMessageModal.js | 3 ++- jam-ui/src/store/features/peopleSlice.js | 7 ++++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/jam-ui/src/components/notification/JKTextMessageNotification.js b/jam-ui/src/components/notification/JKTextMessageNotification.js index 0c114b6b5..72db3516b 100644 --- a/jam-ui/src/components/notification/JKTextMessageNotification.js +++ b/jam-ui/src/components/notification/JKTextMessageNotification.js @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'; import { useAuth } from '../../context/AuthContext'; import { useDispatch, useSelector } from 'react-redux'; -import { selectPersonById, fetchPerson } from '../../store/features/peopleSlice'; +import { selectPersonById, fetchPerson, add as addPerson } from '../../store/features/peopleSlice'; import JKMessageButton from '../profile/JKMessageButton'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import ProfileAvatar from '../profile/JKProfileAvatar'; @@ -26,6 +26,7 @@ function JKTextMessageNotification(props) { .unwrap() .then(resp => { console.log('after fetch person', resp); + dispatch(addPerson(resp)) }) .catch(error => console.log(error)); } diff --git a/jam-ui/src/components/page/JKPerson.js b/jam-ui/src/components/page/JKPerson.js index 0729c3630..2788dff75 100644 --- a/jam-ui/src/components/page/JKPerson.js +++ b/jam-ui/src/components/page/JKPerson.js @@ -63,8 +63,8 @@ const JKPerson = props => { - {biography} - {biography.length > 0 && ( + { biography } + { biography && biography.length > 0 && ( {' '} more ยป diff --git a/jam-ui/src/components/profile/JKMessageModal.js b/jam-ui/src/components/profile/JKMessageModal.js index 398ec189f..15f4d91c4 100644 --- a/jam-ui/src/components/profile/JKMessageModal.js +++ b/jam-ui/src/components/profile/JKMessageModal.js @@ -85,7 +85,8 @@ const JKMessageModal = props => { }; useEffect(() => { - if (show && messages.length === 0) { + //if (show && messages.length === 0) { + if (show) { fetchMessages(); } }, [show]); diff --git a/jam-ui/src/store/features/peopleSlice.js b/jam-ui/src/store/features/peopleSlice.js index 360b7d2c3..1428517ae 100644 --- a/jam-ui/src/store/features/peopleSlice.js +++ b/jam-ui/src/store/features/peopleSlice.js @@ -38,7 +38,11 @@ export const acceptFriendRequest = createAsyncThunk( export const peopleSlice = createSlice({ name: 'people', initialState, - reducers: {}, + reducers: { + add: (state, action) => { + state.people.push(action.payload) + } + }, extraReducers: (builder) => { builder .addCase(fetchPeople.pending, (state, action) => { @@ -67,5 +71,6 @@ export const selectPersonById = (state, userId) => state.people.find((person) => +export const { add } = peopleSlice.actions; export default peopleSlice.reducer; \ No newline at end of file