diff --git a/src/components/Messaging/Messaging.js b/src/components/Messaging/Messaging.js index 73864015d..5f6f35e0c 100644 --- a/src/components/Messaging/Messaging.js +++ b/src/components/Messaging/Messaging.js @@ -67,22 +67,12 @@ const Messaging = () => { body, } = useStyles(); - const { - messages, - resMessages, - growerMessage, - // loadMessages, - // loadRegions, - } = useContext(MessagingContext); - - console.log(growerMessage); - // useEffect(() => { - // }, []); + const { messages, loadMessages, loadRegions } = useContext(MessagingContext); - // useEffect(() => { - // loadMessages(); - // loadRegions(); - // }, []); + useEffect(() => { + loadMessages(); + loadRegions(); + }, []); const [toggleAnnounceMessage, setToggleAnnounceMessage] = useState(false); const [toggleSurvey, setToggleSurvey] = useState(false); diff --git a/src/context/MessagingContext.js b/src/context/MessagingContext.js index eaf562f26..d64fe280d 100644 --- a/src/context/MessagingContext.js +++ b/src/context/MessagingContext.js @@ -19,7 +19,6 @@ export const MessagingContext = createContext({ export const MessagingProvider = (props) => { const [regions, setRegions] = useState([]); const [messages, setMessages] = useState([]); - const [resMessages, setResMessages] = useState([]); const [growerMessage, setGrowerMessage] = useState({}); const user = JSON.parse(localStorage.getItem('user')); @@ -108,7 +107,6 @@ export const MessagingProvider = (props) => { const loadMessages = async () => { const res = await api.getMessage(user.userName); - if (res && growerMessage) { groupMessageByHandle([growerMessage, ...res.messages]); } else { @@ -126,8 +124,6 @@ export const MessagingProvider = (props) => { const value = { user, messages, - resMessages, - growerMessage, regions, sendMessageFromGrower, loadMessages,