Skip to content

Commit

Permalink
fix: messaging context
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterMotko committed Feb 10, 2022
1 parent 88764cb commit e536c0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
20 changes: 5 additions & 15 deletions src/components/Messaging/Messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 0 additions & 4 deletions src/context/MessagingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down Expand Up @@ -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 {
Expand All @@ -126,8 +124,6 @@ export const MessagingProvider = (props) => {
const value = {
user,
messages,
resMessages,
growerMessage,
regions,
sendMessageFromGrower,
loadMessages,
Expand Down

0 comments on commit e536c0d

Please sign in to comment.