diff --git a/tumblr-replica/.history/src/apis/globalAPI_20211230231839.js b/tumblr-replica/.history/src/apis/globalAPI_20211230231839.js new file mode 100644 index 00000000..21a0a978 --- /dev/null +++ b/tumblr-replica/.history/src/apis/globalAPI_20211230231839.js @@ -0,0 +1,6 @@ +export const MOCK = 0; +export const REAL = 1; +export const SERVICETYPE = ; // Change this to change the source +export const api = 'http://localhost:8000'; +export const apiR = 'https://api.dev.tumbler.social/api'; +export const apiREAL = 'https://api.dev.tumbler.social/api'; diff --git a/tumblr-replica/.history/src/apis/globalAPI_20211230231842.js b/tumblr-replica/.history/src/apis/globalAPI_20211230231842.js new file mode 100644 index 00000000..6cf0ba78 --- /dev/null +++ b/tumblr-replica/.history/src/apis/globalAPI_20211230231842.js @@ -0,0 +1,6 @@ +export const MOCK = 0; +export const REAL = 1; +export const SERVICETYPE = MOCK; // Change this to change the source +export const api = 'http://localhost:8000'; +export const apiR = 'https://api.dev.tumbler.social/api'; +export const apiREAL = 'https://api.dev.tumbler.social/api'; diff --git a/tumblr-replica/.history/src/apis/globalAPI_20211231101249.js b/tumblr-replica/.history/src/apis/globalAPI_20211231101249.js new file mode 100644 index 00000000..21a0a978 --- /dev/null +++ b/tumblr-replica/.history/src/apis/globalAPI_20211231101249.js @@ -0,0 +1,6 @@ +export const MOCK = 0; +export const REAL = 1; +export const SERVICETYPE = ; // Change this to change the source +export const api = 'http://localhost:8000'; +export const apiR = 'https://api.dev.tumbler.social/api'; +export const apiREAL = 'https://api.dev.tumbler.social/api'; diff --git a/tumblr-replica/.history/src/apis/globalAPI_20211231101252.js b/tumblr-replica/.history/src/apis/globalAPI_20211231101252.js new file mode 100644 index 00000000..21a0a978 --- /dev/null +++ b/tumblr-replica/.history/src/apis/globalAPI_20211231101252.js @@ -0,0 +1,6 @@ +export const MOCK = 0; +export const REAL = 1; +export const SERVICETYPE = ; // Change this to change the source +export const api = 'http://localhost:8000'; +export const apiR = 'https://api.dev.tumbler.social/api'; +export const apiREAL = 'https://api.dev.tumbler.social/api'; diff --git a/tumblr-replica/.history/src/apis/globalAPI_20211231101253.js b/tumblr-replica/.history/src/apis/globalAPI_20211231101253.js new file mode 100644 index 00000000..e969d34b --- /dev/null +++ b/tumblr-replica/.history/src/apis/globalAPI_20211231101253.js @@ -0,0 +1,6 @@ +export const MOCK = 0; +export const REAL = 1; +export const SERVICETYPE = REAL; // Change this to change the source +export const api = 'http://localhost:8000'; +export const apiR = 'https://api.dev.tumbler.social/api'; +export const apiREAL = 'https://api.dev.tumbler.social/api'; diff --git a/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231160648.jsx b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231160648.jsx new file mode 100644 index 00000000..64f2440c --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231160648.jsx @@ -0,0 +1,104 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, + Avatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { ListItemButton } from '@mui/material'; +import PropTypes from 'prop-types'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; + +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function SearchList({ chats }) { + console.log(chats); + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.friend_username} +

+

+ {`${chat.friend_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ {chat.text ? ( +

+ {`${chat.blog_username}:${chat.text}`} +

+ ) : null} + {chat.photo ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} + {chat.gif ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} +
+ ) + } +
+
+ )) + ); +} + +SearchList.propTypes = { + chats: PropTypes.arrayOf(Object).isRequired, +}; + +export default SearchList; diff --git a/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231160655.jsx b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231160655.jsx new file mode 100644 index 00000000..1f24a7a6 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231160655.jsx @@ -0,0 +1,104 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, + Avatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { ListItemButton } from '@mui/material'; +import PropTypes from 'prop-types'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; + +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function SearchList({ chats }) { + console.log(chats); + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log() + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.friend_username} +

+

+ {`${chat.friend_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ {chat.text ? ( +

+ {`${chat.blog_username}:${chat.text}`} +

+ ) : null} + {chat.photo ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} + {chat.gif ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} +
+ ) + } +
+
+ )) + ); +} + +SearchList.propTypes = { + chats: PropTypes.arrayOf(Object).isRequired, +}; + +export default SearchList; diff --git a/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231160714.jsx b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231160714.jsx new file mode 100644 index 00000000..e21b74a4 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231160714.jsx @@ -0,0 +1,103 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, + Avatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { ListItemButton } from '@mui/material'; +import PropTypes from 'prop-types'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; + +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function SearchList({ chats }) { + console.log(chats); + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.friend_username} +

+

+ {`${chat.friend_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ {chat.text ? ( +

+ {`${chat.blog_username}:${chat.text}`} +

+ ) : null} + {chat.photo ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} + {chat.gif ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} +
+ ) + } +
+
+ )) + ); +} + +SearchList.propTypes = { + chats: PropTypes.arrayOf(Object).isRequired, +}; + +export default SearchList; diff --git a/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162109.jsx b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162109.jsx new file mode 100644 index 00000000..85f65a0a --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162109.jsx @@ -0,0 +1,104 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, + Avatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { ListItemButton } from '@mui/material'; +import PropTypes from 'prop-types'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; + +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function SearchList({ chats }) { + console.log(chats); + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.friend_username} +

+

+ {`${chat.friend_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ {chat.text ? ( +

+ {`${chat.blog_username}:${chat.text}`} +

+ ) : null} + {chat.photo ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} + {chat.gif ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} +
+ ) + } +
+
+ )) + ); +} + +SearchList.propTypes = { + chats: PropTypes.arrayOf(Object).isRequired, +}; + +export default SearchList; diff --git a/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162111.jsx b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162111.jsx new file mode 100644 index 00000000..1f24a7a6 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162111.jsx @@ -0,0 +1,104 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, + Avatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { ListItemButton } from '@mui/material'; +import PropTypes from 'prop-types'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; + +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function SearchList({ chats }) { + console.log(chats); + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log() + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.friend_username} +

+

+ {`${chat.friend_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ {chat.text ? ( +

+ {`${chat.blog_username}:${chat.text}`} +

+ ) : null} + {chat.photo ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} + {chat.gif ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} +
+ ) + } +
+
+ )) + ); +} + +SearchList.propTypes = { + chats: PropTypes.arrayOf(Object).isRequired, +}; + +export default SearchList; diff --git a/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162116.jsx b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162116.jsx new file mode 100644 index 00000000..afa1e629 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162116.jsx @@ -0,0 +1,104 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, + Avatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { ListItemButton } from '@mui/material'; +import PropTypes from 'prop-types'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; + +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function SearchList({ chats }) { + console.log(chats); + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log( User.primaryBlogId) + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.friend_username} +

+

+ {`${chat.friend_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ {chat.text ? ( +

+ {`${chat.blog_username}:${chat.text}`} +

+ ) : null} + {chat.photo ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} + {chat.gif ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} +
+ ) + } +
+
+ )) + ); +} + +SearchList.propTypes = { + chats: PropTypes.arrayOf(Object).isRequired, +}; + +export default SearchList; diff --git a/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162118.jsx b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162118.jsx new file mode 100644 index 00000000..5b3e82a9 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162118.jsx @@ -0,0 +1,105 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, + Avatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { ListItemButton } from '@mui/material'; +import PropTypes from 'prop-types'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; + +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function SearchList({ chats }) { + console.log(chats); + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log( User.primaryBlogId); + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.friend_username} +

+

+ {`${chat.friend_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ {chat.text ? ( +

+ {`${chat.blog_username}:${chat.text}`} +

+ ) : null} + {chat.photo ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} + {chat.gif ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} +
+ ) + } +
+
+ )) + ); +} + +SearchList.propTypes = { + chats: PropTypes.arrayOf(Object).isRequired, +}; + +export default SearchList; diff --git a/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162123.jsx b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162123.jsx new file mode 100644 index 00000000..53644cc5 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162123.jsx @@ -0,0 +1,105 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, + Avatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { ListItemButton } from '@mui/material'; +import PropTypes from 'prop-types'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; + +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function SearchList({ chats }) { + console.log(chats); + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log( User.primaryBlogId); + console.log() + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.friend_username} +

+

+ {`${chat.friend_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ {chat.text ? ( +

+ {`${chat.blog_username}:${chat.text}`} +

+ ) : null} + {chat.photo ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} + {chat.gif ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} +
+ ) + } +
+
+ )) + ); +} + +SearchList.propTypes = { + chats: PropTypes.arrayOf(Object).isRequired, +}; + +export default SearchList; diff --git a/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162131.jsx b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162131.jsx new file mode 100644 index 00000000..df20d5bf --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162131.jsx @@ -0,0 +1,105 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, + Avatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { ListItemButton } from '@mui/material'; +import PropTypes from 'prop-types'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; + +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function SearchList({ chats }) { + console.log(chats); + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log( User.primaryBlogId); + console.log(chat.friend_id) + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.friend_username} +

+

+ {`${chat.friend_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ {chat.text ? ( +

+ {`${chat.blog_username}:${chat.text}`} +

+ ) : null} + {chat.photo ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} + {chat.gif ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} +
+ ) + } +
+
+ )) + ); +} + +SearchList.propTypes = { + chats: PropTypes.arrayOf(Object).isRequired, +}; + +export default SearchList; diff --git a/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162132.jsx b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162132.jsx new file mode 100644 index 00000000..a4eab110 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162132.jsx @@ -0,0 +1,105 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, + Avatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { ListItemButton } from '@mui/material'; +import PropTypes from 'prop-types'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; + +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function SearchList({ chats }) { + console.log(chats); + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log( User.primaryBlogId); + console.log(chat.friend_id); + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.friend_username} +

+

+ {`${chat.friend_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ {chat.text ? ( +

+ {`${chat.blog_username}:${chat.text}`} +

+ ) : null} + {chat.photo ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} + {chat.gif ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} +
+ ) + } +
+
+ )) + ); +} + +SearchList.propTypes = { + chats: PropTypes.arrayOf(Object).isRequired, +}; + +export default SearchList; diff --git a/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162139.jsx b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162139.jsx new file mode 100644 index 00000000..80e0ac46 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatSearchBar/subcomponents/SearchList_20211231162139.jsx @@ -0,0 +1,105 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, + Avatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { ListItemButton } from '@mui/material'; +import PropTypes from 'prop-types'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; + +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function SearchList({ chats }) { + console.log(chats); + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id); + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.friend_username} +

+

+ {`${chat.friend_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ {chat.text ? ( +

+ {`${chat.blog_username}:${chat.text}`} +

+ ) : null} + {chat.photo ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} + {chat.gif ? ( +

+ {`${chat.blog_username}:sent a post`} +

+ ) : null} +
+ ) + } +
+
+ )) + ); +} + +SearchList.propTypes = { + chats: PropTypes.arrayOf(Object).isRequired, +}; + +export default SearchList; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222651.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222651.jsx new file mode 100644 index 00000000..b00babb2 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222651.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; + +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222653.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222653.jsx new file mode 100644 index 00000000..53d5e059 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222653.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222655.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222655.jsx new file mode 100644 index 00000000..77fdf1d5 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222655.jsx @@ -0,0 +1,99 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +export function TumblrItem({ tumblrName, tumblrTitle, tumblrIcon }) { + import +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222658.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222658.jsx new file mode 100644 index 00000000..53d5e059 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222658.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222706.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222706.jsx new file mode 100644 index 00000000..22af0845 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222706.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import Tum +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222708.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222708.jsx new file mode 100644 index 00000000..202a77aa --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222708.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222834.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222834.jsx new file mode 100644 index 00000000..20b21e9b --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222834.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222945.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222945.jsx new file mode 100644 index 00000000..f93da4d3 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230222945.jsx @@ -0,0 +1,95 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223423.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223423.jsx new file mode 100644 index 00000000..0dd6dfee --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223423.jsx @@ -0,0 +1,96 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../../states/usertumblr/usertumblrSlice'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223448.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223448.jsx new file mode 100644 index 00000000..f800d0dc --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223448.jsx @@ -0,0 +1,97 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../../states/usertumblr/usertumblrSlice'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223550.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223550.jsx new file mode 100644 index 00000000..7aad3e60 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223550.jsx @@ -0,0 +1,97 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../../../states/usertumblr/usertumblrSlice'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223553.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223553.jsx new file mode 100644 index 00000000..58170607 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223553.jsx @@ -0,0 +1,97 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223604.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223604.jsx new file mode 100644 index 00000000..8075221d --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223604.jsx @@ -0,0 +1,97 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223736.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223736.jsx new file mode 100644 index 00000000..54facefe --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223736.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { chooseBlueItem, tumblrSelection, useOutsideAlerter } from '../interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223745.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223745.jsx new file mode 100644 index 00000000..a2177444 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223745.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { chooseBlueItem, tumblrSelection, useOutsideAlerter } from '../../interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223756.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223756.jsx new file mode 100644 index 00000000..b08c55e4 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223756.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { chooseBlueItem, tumblrSelection, useOutsideAlerter } from '../../components/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223800.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223800.jsx new file mode 100644 index 00000000..7a660c93 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223800.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { chooseBlueItem, tumblrSelection, useOutsideAlerter } from '../../components/Ninteractions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223803.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223803.jsx new file mode 100644 index 00000000..a5ca8099 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223803.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { chooseBlueItem, tumblrSelection, useOutsideAlerter } from '../../components/NavigationBarinteractions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223804.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223804.jsx new file mode 100644 index 00000000..ac113792 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223804.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { chooseBlueItem, tumblrSelection, useOutsideAlerter } from '../../components/NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223808.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223808.jsx new file mode 100644 index 00000000..4364776f --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223808.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { chooseBlueItem, tumblrSelection, useOutsideAlerter } from '../../components/NavigationBar/interactionsinteractions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223811.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223811.jsx new file mode 100644 index 00000000..ac113792 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223811.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { chooseBlueItem, tumblrSelection, useOutsideAlerter } from '../../components/NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223819.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223819.jsx new file mode 100644 index 00000000..ea5dcd8f --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223819.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { chooseBlueItem, tumblrSelection, useOutsideAlerter } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223826.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223826.jsx new file mode 100644 index 00000000..aaae8517 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223826.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { chooseBlueItem, tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223828.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223828.jsx new file mode 100644 index 00000000..04483721 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230223828.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224122.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224122.jsx new file mode 100644 index 00000000..d5feef13 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224122.jsx @@ -0,0 +1,99 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + +
+ {(blogState.isLoading) + ? ( + ) + : ( + (blogState.blogs).map((blog) => ( + + )) + + ) } +
+
+ {newMessagePress1 && } + + + +
+ +
+ + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} +
+
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224130.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224130.jsx new file mode 100644 index 00000000..3e60c680 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224130.jsx @@ -0,0 +1,99 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224203.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224203.jsx new file mode 100644 index 00000000..85b259a6 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224203.jsx @@ -0,0 +1,100 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + const chevronRef = useRef(null); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224211.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224211.jsx new file mode 100644 index 00000000..0b6af0e0 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224211.jsx @@ -0,0 +1,100 @@ +import React, { useEffect, useRef } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + const chevronRef = useRef(null); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224908.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224908.jsx new file mode 100644 index 00000000..9865d97f --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224908.jsx @@ -0,0 +1,97 @@ +import React, { useEffect, useRef } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + const chevronRef = useRef(null); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224913.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224913.jsx new file mode 100644 index 00000000..0e0034c6 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224913.jsx @@ -0,0 +1,96 @@ +import React, { useEffect, useRef } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + const chevronRef = useRef(null); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224922.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224922.jsx new file mode 100644 index 00000000..9865d97f --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224922.jsx @@ -0,0 +1,97 @@ +import React, { useEffect, useRef } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + const chevronRef = useRef(null); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224924.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224924.jsx new file mode 100644 index 00000000..0b6af0e0 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224924.jsx @@ -0,0 +1,100 @@ +import React, { useEffect, useRef } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + const chevronRef = useRef(null); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224926.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224926.jsx new file mode 100644 index 00000000..4b5ead06 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224926.jsx @@ -0,0 +1,100 @@ +import React, { useEffect, } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + const chevronRef = useRef(null); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224930.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224930.jsx new file mode 100644 index 00000000..dcef90b5 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224930.jsx @@ -0,0 +1,100 @@ +import React, { useEffect, useRe } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + const chevronRef = useRef(null); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224932.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224932.jsx new file mode 100644 index 00000000..0b6af0e0 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230224932.jsx @@ -0,0 +1,100 @@ +import React, { useEffect, useRef } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + const chevronRef = useRef(null); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225134.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225134.jsx new file mode 100644 index 00000000..4b5ead06 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225134.jsx @@ -0,0 +1,100 @@ +import React, { useEffect, } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; +import { tumblrSelection } from '../NavigationBar/interactions'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + const chevronRef = useRef(null); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225144.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225144.jsx new file mode 100644 index 00000000..20b21e9b --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225144.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225145.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225145.jsx new file mode 100644 index 00000000..202a77aa --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225145.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { TumblrItem } from '../NavigationBar/subcomponents/NotificationsDropDown'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225148.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225148.jsx new file mode 100644 index 00000000..b5b33c44 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225148.jsx @@ -0,0 +1,97 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225157.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225157.jsx new file mode 100644 index 00000000..b00babb2 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225157.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; + +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225216.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225216.jsx new file mode 100644 index 00000000..f2acd69d --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225216.jsx @@ -0,0 +1,99 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { selectBlogs } from '../../../states/usertumblr/usertumblrSlice'; + +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225240.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225240.jsx new file mode 100644 index 00000000..fb246682 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225240.jsx @@ -0,0 +1,100 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { selectBlogs } from '../../../states/usertumblr/usertumblrSlice'; + +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225252.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225252.jsx new file mode 100644 index 00000000..5f89b74c --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225252.jsx @@ -0,0 +1,100 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../../states/usertumblr/usertumblrSlice'; + +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225310.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225310.jsx new file mode 100644 index 00000000..b385234d --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230225310.jsx @@ -0,0 +1,100 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; + +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + const blogState = useSelector(selectBlogs); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230231803.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230231803.jsx new file mode 100644 index 00000000..bd0f6adb --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230231803.jsx @@ -0,0 +1,99 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; +import { selectBlogs } from '../../states/usertumblr/usertumblrSlice'; + +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230231810.jsx b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230231810.jsx new file mode 100644 index 00000000..08071798 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/ChatTo_20211230231810.jsx @@ -0,0 +1,98 @@ +import React, { useEffect } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import ListSubheader from '@mui/material/ListSubheader'; +import List from '@mui/material/List'; +import { + Divider, + Box, + ListItem, +} from '@material-ui/core'; + +import { + newMessagePress, +} from '../../slices/chatmodule/chatmoduleSlice'; +import { getAllChats, recentlyFollowed } from '../../slices/chatmodule/chatmoduleAPI'; +import ChatList from './subcomponents/ChatList'; +// import ChatSearch from './subcomponents/ChatSearch'; +import { selectUser } from '../../states/User/UserSlice'; +import SearchBar from '../ChatSearchBar/SearchBar'; +import './css/ChatList.css'; +/** + * This function is for the ChatTo component this component has a search + * bar to search for friend to chat with + * @method + * @returns {*} ChatTo componenet + */ +function ChatTo() { + const chats = useSelector((state) => state.Chat.chats); + const User = useSelector(selectUser); + // const ListOpen = useSelector(true); + const recentlyFollowed1 = useSelector((state) => state.Chat.recentlyfollowed); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const dispatch = useDispatch(); + useEffect(() => { + // eslint-disable-next-line no-unused-expressions + newMessagePress1 + ? dispatch(recentlyFollowed(User)) : dispatch(getAllChats(User)); + }, []); + return ( +
+ } + > + + + + + + {newMessagePress1 && } + + + + + + + + {newMessagePress1 && } + + {console.log(recentlyFollowed1)} + +
+ ); +} +export default ChatTo; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155928.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155928.jsx new file mode 100644 index 00000000..fe008bcf --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155928.jsx @@ -0,0 +1,106 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + c + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155931.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155931.jsx new file mode 100644 index 00000000..ec3d6596 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155931.jsx @@ -0,0 +1,106 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155934.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155934.jsx new file mode 100644 index 00000000..0183ee62 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155934.jsx @@ -0,0 +1,106 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log() + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155940.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155940.jsx new file mode 100644 index 00000000..ce44441e --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155940.jsx @@ -0,0 +1,106 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId) + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155942.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155942.jsx new file mode 100644 index 00000000..b4d03408 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155942.jsx @@ -0,0 +1,107 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155946.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155946.jsx new file mode 100644 index 00000000..061e2d99 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155946.jsx @@ -0,0 +1,107 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155949.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155949.jsx new file mode 100644 index 00000000..1c7080e7 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155949.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155957.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155957.jsx new file mode 100644 index 00000000..87288491 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231155957.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log() + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160003.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160003.jsx new file mode 100644 index 00000000..e6d5271b --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160003.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id) + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160005.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160005.jsx new file mode 100644 index 00000000..11d15eab --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160005.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id,) + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160007.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160007.jsx new file mode 100644 index 00000000..ce0a400d --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160007.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id,chat.friend_id) + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160009.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160009.jsx new file mode 100644 index 00000000..723a8234 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160009.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id,chat.friend_name) + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160011.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160011.jsx new file mode 100644 index 00000000..69c7b4a7 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160011.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id,chat.friend_name); + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160013.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160013.jsx new file mode 100644 index 00000000..5e4d208c --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160013.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id, chat.friend_name); + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160015.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160015.jsx new file mode 100644 index 00000000..2530a6cd --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160015.jsx @@ -0,0 +1,107 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id, chat.friend_name); + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160154.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160154.jsx new file mode 100644 index 00000000..e0550a46 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160154.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id, chat.friend_name); + + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160158.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160158.jsx new file mode 100644 index 00000000..fb7cc27f --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160158.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id, chat.friend_name); + consol + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160202.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160202.jsx new file mode 100644 index 00000000..eaa257fb --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160202.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id, chat.friend_name); + console.log(chat) + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160204.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160204.jsx new file mode 100644 index 00000000..b5638113 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160204.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id, chat.friend_name); + console.log(chat[0]) + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160208.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160208.jsx new file mode 100644 index 00000000..a404ef67 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160208.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id, chat.friend_name); + console.log(chats[]) + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160209.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160209.jsx new file mode 100644 index 00000000..9579cbe6 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160209.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id, chat.friend_name); + console.log(chats[0]) + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160213.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160213.jsx new file mode 100644 index 00000000..eaa257fb --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160213.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id, chat.friend_name); + console.log(chat) + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160218.jsx b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160218.jsx new file mode 100644 index 00000000..399691a7 --- /dev/null +++ b/tumblr-replica/.history/src/components/ChatTo/subcomponents/ChatList_20211231160218.jsx @@ -0,0 +1,108 @@ +/* eslint-disable operator-linebreak */ +import React from 'react'; +import { useSelector, useDispatch } from 'react-redux'; +import { + ListItemAvatar, +} from '@material-ui/core'; +import { Box } from '@mui/system'; +import { Divider, ListItemButton } from '@mui/material'; +import { + getChatRoomId, +} from '../../../slices/chatmodule/chatmoduleAPI'; +import { + removeAvaterID, +} from '../../../slices/chatmodule/chatmoduleSlice'; +import { selectUser } from '../../../states/User/UserSlice'; +import '../../ChatListResp/css/ChatListResp.css'; +/** + * This function is for the ChatList component this component is used + * to disply the friends that the user can chat with or search for them for chatting + * @method + * @param {array} chats chats is an array for the chat participants's info + * @returns {*} ChatList componenet + */ +function ChatList({ chats }) { + const User = useSelector(selectUser); + const dispatch = useDispatch(); + const newMessagePress1 = useSelector((state) => state.Chat.newmessagepress); + const chatBox = useSelector((state) => state.Chat.chatbox); + const avatars = useSelector((state) => state.Chat.avatars); + console.log(`heloo from chatlist ${chats}`); + return ( + chats.map((chat) => ( +
+ { + const newavatars = avatars.filter((el) => chat.friend_id === el.elem.friend_id); + console.log(avatars); + if (newavatars.length) { + dispatch(removeAvaterID(newavatars[0])); + } else + if ((chatBox.length + && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id, chat.friend_name); + console.log(chat); + dispatch(getChatRoomId({ + blogsID: { + from_blog_id: User.primaryBlogId, + to_blog_id: newMessagePress1 ? chat.friend_id : chat.friend_id, + }, + User, + elem: chat, + })); + } + }} + > + + + + { + newMessagePress1 ? ( + +

+ {chat.blog_username} +

+

+ {`${chat.blog_title}`} +

+
+ ) : ( + +

+ {chat.friend_username} +

+ +

+ {`${chat.blog_username} : `} +

+ {chat.text && ( +

+ {`${chat.text}`} +

+ )} + {chat.photo && ( +

+ sent a Photo +

+ )} +
+
+ ) + } +
+ +
+ )) + ); +} +export default ChatList; diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231132419.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231132419.jsx new file mode 100644 index 00000000..e69de29b diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231132739.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231132739.jsx new file mode 100644 index 00000000..0a0bd0ec --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231132739.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import NavBar from '../ProfileNavBar'; + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const HomeIcon = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); \ No newline at end of file diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231132743.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231132743.jsx new file mode 100644 index 00000000..db5cd164 --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231132743.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import NavBar from '../ProfileNavBar'; + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const HomeIcon = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134846.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134846.jsx new file mode 100644 index 00000000..72b6c7f7 --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134846.jsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const HomeIcon = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134901.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134901.jsx new file mode 100644 index 00000000..e03079ac --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134901.jsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(< CloseClicked={MockedCloseClicked} />); + const HomeIcon = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134907.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134907.jsx new file mode 100644 index 00000000..1fd855ee --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134907.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(< CloseClicked={MockedCloseClicked} />); + const HomeIcon = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134932.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134932.jsx new file mode 100644 index 00000000..9553fe1b --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134932.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const HomeIcon = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134942.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134942.jsx new file mode 100644 index 00000000..f002eb19 --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134942.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import FollowingPage from '' + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const HomeIcon = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134948.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134948.jsx new file mode 100644 index 00000000..1a2f25f1 --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134948.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import FollowingPage from '../' + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const HomeIcon = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134956.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134956.jsx new file mode 100644 index 00000000..0f0b4f80 --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134956.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import FollowingPage from '../FollowingPage' + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const HomeIcon = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134958.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134958.jsx new file mode 100644 index 00000000..8d7358b9 --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231134958.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import FollowingPage from '../FollowingPage'; + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const HomeIcon = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135018.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135018.jsx new file mode 100644 index 00000000..8d6d6cb1 --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135018.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import FollowingPage from '../FollowingPage'; + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const HomeIcon = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135022.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135022.jsx new file mode 100644 index 00000000..15d58f68 --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135022.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import FollowingPage from '../FollowingPage'; + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const HomeIcon = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135044.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135044.jsx new file mode 100644 index 00000000..445ec329 --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135044.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import FollowingPage from '../FollowingPage'; + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135048.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135048.jsx new file mode 100644 index 00000000..837486ef --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135048.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import FollowingPage from '../FollowingPage'; + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const Follow = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135051.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135051.jsx new file mode 100644 index 00000000..8e3ebad3 --- /dev/null +++ b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231135051.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import '@testing-library/jest-dom/extend-expect'; +import FollowingPage from '../FollowingPage'; + +const MockedCloseClicked = jest.fn(); + +describe('testing icons', () => { + it('test the dashboard icon is exist ', async () => { + render(); + const FollowButton = screen.getByTestId('HomeIcon'); + expect(HomeIcon).toBeInTheDocument(); + }); + it('test if follow btn appears', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('FollowBtn'); + expect(InputElement).toBeVisible(); + }); + it('test if the block button disappear if the human icon clicked twice', + async () => { + render(); + const Human = screen.getByTestId('HumanIcon'); + fireEvent.click(Human); + const InputElement = screen.getByTestId('BlockBtn'); + fireEvent.click(Human); + expect(InputElement).not.toBeVisible(); + }); +}); diff --git a/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231152211.jsx b/tumblr-replica/.history/src/components/FollowingPage/__test__/FollowingPage.test_20211231152211.jsx new file mode 100644 index 00000000..e69de29b diff --git a/tumblr-replica/.history/src/slices/chatmodule/chatmoduleSlice_20211230231736.js b/tumblr-replica/.history/src/slices/chatmodule/chatmoduleSlice_20211230231736.js new file mode 100644 index 00000000..f74a8c6a --- /dev/null +++ b/tumblr-replica/.history/src/slices/chatmodule/chatmoduleSlice_20211230231736.js @@ -0,0 +1,323 @@ +import { createSlice } from '@reduxjs/toolkit'; +import { + getChatFeed, getAllChats, searchForChat, getChatRoomIdRes, getBlogIdFromBlogUN, setBlogFriendName, + sendMessage, chatSearch, recentlyFollowed, uploadPhoto, getAllGifs, deleteMessages, getChatRoomId, +} from './chatmoduleAPI'; +import { MOCK, SERVICETYPE } from '../../apis/globalAPI'; + +const initialState = { + gifs: [], + chatbox: [], + chats: [], + avatars: [], + chatfeed: [], + newmessage: false, + Isloading: false, + newmessagepress: false, + recentlyfollowed: [], + newmessagepressres: false, + chatroomid: '', + blogsToChat: [], + userbloginfo: '', + friendbloginfo: '', +}; + +const chatReducer = createSlice({ + name: 'Chat', + initialState, + reducers: { + setFeedMessages: (state, action) => { + const newstate = state; + newstate.messages = action.payload.messages; + }, + setGifs: (state, action) => { + const newstate = state; + newstate.gifs = action.payload.gifs; + }, + setChatBoxesID: (state, { payload }) => { + if (state.chatbox.length) { + console.log(state.chatbox.length); + const newstate = state; + newstate.avatars.push(state.chatbox[0]); + newstate.chatbox = []; + console.log('set chat boxeses id entered'); + } + state.chatbox.push(payload); + }, + newMessagePress: (state) => { + const newstate = state; + newstate.newmessagepress = !state.newmessagepress; + }, + newMessagePressRes: (state) => { + const newstate = state; + newstate.newmessagepressres = !state.newmessagepressres; + console.log(newstate.newmessagepressres); + }, + removeChatBoxID: (state) => { + const newstate = state; + newstate.avatars.push(newstate.chatbox[0]); + newstate.chatbox = []; + // newstate.avatars.push(action.payload); + }, + removeChatBoxIDOnly: (state) => { + const newstate = state; + newstate.chatbox = []; + }, + removeAvaterID: (state, { payload }) => { + const newstate = state; + const newAvaters = state.avatars.filter((elem) => elem.res.response.chat_room_id + !== payload?.res.response.chat_room_id); + console.log(newAvaters); + newstate.avatars = newAvaters; + if (state.chatbox.length) { + console.log(state.chatbox.length); + newstate.avatars.push(state.chatbox[0]); + newstate.chatbox = []; + } + newstate.chatbox.push(payload); + }, + toggleNewMessage: (state) => { + const newstate = state; + newstate.newmessage = !state.newmessage; + }, + chatUpdate: (state, { payload }) => { + const newstate = state; + const pay = { + text: payload.text, + photo: payload.photo, + gif: payload.gif, + read: payload.read, + blog_username: payload.from_blog_username, + from_blog_id: payload.from_blog_id, + blog_avatar: payload.from_blog_avatar, + blog_avatar_shape: payload.from_blog_avatar_shape, + blog_title: payload.blog_title, + }; + newstate.chatfeed.push(pay); + }, + filterBlogsChat: (state, { payload }) => { + const newstate = state; + console.log(newstate.blogsToChat); + const newFilter = newstate.blogsToChat.filter( + (value) => value?.friend_username.toLowerCase().includes(payload.toLowerCase()), + ); + newstate.blogsToChat = newFilter; + if (payload.length === 0) { + newstate.blogsToChat = []; + } + }, + }, + extraReducers: { + [getAllChats.pending]: () => { + console.log('pendddddd'); + console.log(initialState); + }, + [getAllChats.fulfilled]: (state, { payload }) => { + const newstate = state; + console.log('Get all chats is done'); + if (payload?.meta.status === '200') { + newstate.chats = payload?.response.chat_messages; + } + }, + [getAllChats.rejected]: () => { + console.log('pendddddd'); + }, + [getChatFeed.pending]: () => { + + }, + [getChatFeed.fulfilled]: (state, { payload }) => { + const newstate = state; + if (payload?.meta.status === '200') { + newstate.chatfeed = payload?.response.chat_messages; + console.log('chat feed is got suc '); + } + }, + [getChatFeed.rejected]: () => { + + }, + [sendMessage.pending]: () => { + + }, + [sendMessage.fulfilled]: (state, { payload }) => { + console.log(payload); + if (SERVICETYPE === MOCK) { + const newstate = state; + newstate.chatfeed.push(payload?.messageBody); + } else { + const newstate = state; + if (payload?.res.meta.status === '200') { + console.log(payload?.messageBody); + newstate.chatfeed.push(payload?.messageBody); + console.log('chat feed is got suc '); + } + } + }, + [sendMessage.rejected]: () => { + + }, + [chatSearch.pending]: () => { + + }, + [chatSearch.fulfilled]: (state, action) => { + const newstate = state; + newstate.chats = action.payload; + console.log('Chat list to resp '); + console.log(newstate.chats); + }, + [chatSearch.rejected]: () => { + + }, + [recentlyFollowed.pending]: () => { + + }, + [recentlyFollowed.fulfilled]: (state, { payload }) => { + if (SERVICETYPE !== MOCK) { + console.log(payload); + const newstate = state; + if (payload?.meta.status === '200') { + newstate.recentlyfollowed = payload?.response.followings; + console.log(`payload ${payload?.response.followings}`); + console.log(newstate.recentlyfollowed); + } + } else { + console.log(payload); + const newstate = state; + if (payload?.meta.status === '200') { + newstate.recentlyfollowed = payload?.response.chat_messages; + } + } + }, + [recentlyFollowed.rejected]: () => { + + }, + [uploadPhoto.pending]: () => { + + }, + [uploadPhoto.fulfilled]: (state, action) => { + const newstate = state; + newstate.chats = action.payload; + console.log('Chat list to resp '); + console.log(newstate.chats); + }, + [uploadPhoto.rejected]: () => { + + }, + [getAllGifs.pending]: () => { + + }, + [getAllGifs.fulfilled]: (state, action) => { + const newstate = state; + newstate.chats = action.payload; + console.log('Chat list to resp '); + console.log(newstate.chats); + }, + [getAllGifs.rejected]: () => { + + }, + [deleteMessages.pending]: () => { + + }, + [deleteMessages.fulfilled]: (state, { payload }) => { + const newstate = state; + if (payload?.meta.status === '200') { + console.log('conversation deleted suc'); + newstate.chatfeed = []; + } + }, + [deleteMessages.rejected]: () => { + + }, + [getChatRoomId.pending]: () => { + + }, + [getChatRoomId.fulfilled]: (state, { payload }) => { + const newstate = state; + if (payload?.res.meta.status === '200') { + newstate.chatroomid = payload?.res.response.chat_room_id; + console.log(`chat room id is ${newstate.chatroomid}`); + if (state.chatbox.length) { + console.log(state.chatbox.length); + newstate.avatars.push(state.chatbox[0]); + newstate.chatbox = []; + console.log('set chat boxeses id entered'); + } + state.chatbox.push(payload); + console.log(payload); + } + }, + [getChatRoomId.rejected]: () => { + + }, + [searchForChat.pending]: () => { + + }, + [searchForChat.fulfilled]: (state, { payload }) => { + console.log('hiiiiiiiiiiiiiiiiiiiiiiii'); + console.log(payload); + const newstate = state; + if (payload?.meta.status === '200') { + newstate.blogsToChat = payload?.response.blogs; + } + }, + [searchForChat.rejected]: () => { + + }, + [getChatRoomIdRes.pending]: () => { + + }, + [getChatRoomIdRes.fulfilled]: () => { + /* + console.log('hiiiiiiiiiiiiiiiiiiiiiiii from getChatRoomIdRes'); + if (payload?.meta.status === '200') { + return payload?.response.chat_room_id; + } + return ''; + */ + }, + [getChatRoomIdRes.rejected]: () => { + + }, + [getBlogIdFromBlogUN.pending]: () => { + + }, + [getBlogIdFromBlogUN.fulfilled]: () => { + /* + console.log('hiiiiiiiiiiiiiiiiiiiiiiii from getChatRoomIdRes'); + // const newstate = state; + if (payload?.res.meta.status === '200') { + // if (payload?.isUser) { + // newstate.userbloginfo = payload?.res.response; + // } else { + // newstate.friendbloginfo = payload?.res.response; + // } + return payload?.res.response.id; + } + return ''; + */ + }, + [getBlogIdFromBlogUN.rejected]: () => { + + }, + [setBlogFriendName.pending]: () => { + + }, + [setBlogFriendName.fulfilled]: (state, { payload }) => { + console.log('hiiiiiiiiiiiiiiiiiiiiiiii from setBlogFriendName'); + const newstate = state; + if (payload?.meta.status === '200') { + newstate.friendbloginfo = payload?.response; + } + }, + [setBlogFriendName.rejected]: () => { + + }, + }, +}); + +export default chatReducer.reducer; +export const { + addMessage, loadChat, setFeedMessages, + setGifs, setChatBoxesID, newMessagePress, removeChatBoxID, removeAvaterID, + toggleNewMessage, filterBlogsChat, + deleteConversation, setChats, removeChatBoxIDOnly, chatUpdate, newMessagePressRes, +} = chatReducer.actions; diff --git a/tumblr-replica/.history/src/slices/chatmodule/chatmoduleSlice_20211230232306.js b/tumblr-replica/.history/src/slices/chatmodule/chatmoduleSlice_20211230232306.js new file mode 100644 index 00000000..1e1c3505 --- /dev/null +++ b/tumblr-replica/.history/src/slices/chatmodule/chatmoduleSlice_20211230232306.js @@ -0,0 +1,324 @@ +import { createSlice } from '@reduxjs/toolkit'; +import { + getChatFeed, getAllChats, searchForChat, getChatRoomIdRes, getBlogIdFromBlogUN, setBlogFriendName, + sendMessage, chatSearch, recentlyFollowed, uploadPhoto, getAllGifs, deleteMessages, getChatRoomId, +} from './chatmoduleAPI'; +import { MOCK, SERVICETYPE } from '../../apis/globalAPI'; + +const initialState = { + gifs: [], + chatbox: [], + chats: [], + avatars: [], + chatfeed: [], + newmessage: false, + Isloading: false, + newmessagepress: false, + recentlyfollowed: [], + newmessagepressres: false, + chatroomid: '', + blogsToChat: [], + userbloginfo: '', + friendbloginfo: '', +}; + +const chatReducer = createSlice({ + name: 'Chat', + initialState, + reducers: { + setFeedMessages: (state, action) => { + const newstate = state; + newstate.messages = action.payload.messages; + }, + setGifs: (state, action) => { + const newstate = state; + newstate.gifs = action.payload.gifs; + }, + setChatBoxesID: (state, { payload }) => { + if (state.chatbox.length) { + console.log(state.chatbox.length); + const newstate = state; + newstate.avatars.push(state.chatbox[0]); + newstate.chatbox = []; + console.log('set chat boxeses id entered'); + } + state.chatbox.push(payload); + }, + newMessagePress: (state) => { + const newstate = state; + newstate.newmessagepress = !state.newmessagepress; + }, + newMessagePressRes: (state) => { + const newstate = state; + newstate.newmessagepressres = !state.newmessagepressres; + console.log(newstate.newmessagepressres); + }, + removeChatBoxID: (state) => { + const newstate = state; + newstate.avatars.push(newstate.chatbox[0]); + newstate.chatbox = []; + // newstate.avatars.push(action.payload); + }, + removeChatBoxIDOnly: (state) => { + const newstate = state; + newstate.chatbox = []; + }, + removeAvaterID: (state, { payload }) => { + const newstate = state; + const newAvaters = state.avatars.filter((elem) => elem.res.response.chat_room_id + !== payload?.res.response.chat_room_id); + console.log(newAvaters); + newstate.avatars = newAvaters; + if (state.chatbox.length) { + console.log(state.chatbox.length); + newstate.avatars.push(state.chatbox[0]); + newstate.chatbox = []; + } + newstate.chatbox.push(payload); + }, + toggleNewMessage: (state) => { + const newstate = state; + newstate.newmessage = !state.newmessage; + }, + chatUpdate: (state, { payload }) => { + const newstate = state; + const pay = { + text: payload.text, + photo: payload.photo, + gif: payload.gif, + read: payload.read, + blog_username: payload.from_blog_username, + from_blog_id: payload.from_blog_id, + blog_avatar: payload.from_blog_avatar, + blog_avatar_shape: payload.from_blog_avatar_shape, + blog_title: payload.blog_title, + }; + newstate.chatfeed.push(pay); + }, + filterBlogsChat: (state, { payload }) => { + const newstate = state; + console.log(newstate.blogsToChat); + const newFilter = newstate.blogsToChat.filter( + (value) => value?.friend_username.toLowerCase().includes(payload.toLowerCase()), + ); + newstate.blogsToChat = newFilter; + if (payload.length === 0) { + newstate.blogsToChat = []; + } + }, + }, + extraReducers: { + [getAllChats.pending]: () => { + console.log('pendddddd'); + console.log(initialState); + }, + [getAllChats.fulfilled]: (state, { payload }) => { + const newstate = state; + console.log('Get all chats is done'); + if (payload?.meta.status === '200') { + newstate.chats = payload?.response.chat_messages; + } + }, + [getAllChats.rejected]: () => { + console.log('pendddddd'); + }, + [getChatFeed.pending]: () => { + + }, + [getChatFeed.fulfilled]: (state, { payload }) => { + const newstate = state; + if (payload?.meta.status === '200') { + newstate.chatfeed = payload?.response.chat_messages; + console.log('chat feed is got suc '); + } + }, + [getChatFeed.rejected]: () => { + + }, + [sendMessage.pending]: () => { + + }, + [sendMessage.fulfilled]: (state, { payload }) => { + console.log(payload); + if (SERVICETYPE === MOCK) { + const newstate = state; + newstate.chatfeed.push(payload?.messageBody); + } else { + const newstate = state; + if (payload?.res.meta.status === '200') { + console.log(payload?.messageBody); + newstate.chatfeed.push(payload?.messageBody); + console.log('chat feed is got suc '); + } + } + }, + [sendMessage.rejected]: () => { + + }, + [chatSearch.pending]: () => { + + }, + [chatSearch.fulfilled]: (state, action) => { + const newstate = state; + newstate.chats = action.payload; + console.log('Chat list to resp '); + console.log(newstate.chats); + }, + [chatSearch.rejected]: () => { + + }, + [recentlyFollowed.pending]: () => { + + }, + [recentlyFollowed.fulfilled]: (state, { payload }) => { + if (SERVICETYPE !== MOCK) { + console.log(payload); + const newstate = state; + if (payload?.meta.status === '200') { + newstate.recentlyfollowed = payload?.response.followings; + console.log(`payload ${payload?.response.followings}`); + console.log(newstate.recentlyfollowed); + } + } else { + console.log(payload); + const newstate = state; + if (payload?.meta.status === '200') { + newstate.recentlyfollowed = payload?.response.chat_messages; + } + } + }, + [recentlyFollowed.rejected]: () => { + + }, + [uploadPhoto.pending]: () => { + + }, + [uploadPhoto.fulfilled]: (state, action) => { + const newstate = state; + newstate.chats = action.payload; + console.log('Chat list to resp '); + console.log(newstate.chats); + }, + [uploadPhoto.rejected]: () => { + + }, + [getAllGifs.pending]: () => { + + }, + [getAllGifs.fulfilled]: (state, action) => { + const newstate = state; + newstate.chats = action.payload; + console.log('Chat list to resp '); + console.log(newstate.chats); + }, + [getAllGifs.rejected]: () => { + + }, + [deleteMessages.pending]: () => { + + }, + [deleteMessages.fulfilled]: (state, { payload }) => { + const newstate = state; + if (payload?.meta.status === '200') { + console.log('conversation deleted suc'); + newstate.chatfeed = []; + } + }, + [deleteMessages.rejected]: () => { + + }, + [getChatRoomId.pending]: () => { + + }, + [getChatRoomId.fulfilled]: (state, { payload }) => { + const newstate = state; + if (payload?.res.meta.status === '200') { + newstate.chatroomid = payload?.res.response.chat_room_id; + console.log(`chat room id is ${newstate.chatroomid}`); + if (state.chatbox.length) { + console.log(state.chatbox.length); + newstate.avatars.push(state.chatbox[0]); + newstate.chatbox = []; + console.log('set chat boxeses id entered'); + } + state.chatbox.push(payload); + console.log(payload); + } + }, + [getChatRoomId.rejected]: () => { + + }, + [searchForChat.pending]: () => { + + }, + [searchForChat.fulfilled]: (state, { payload }) => { + console.log('hiiiiiiiiiiiiiiiiiiiiiiii'); + console.log(payload); + const newstate = state; + if (payload?.meta.status === '200') { + newstate.blogsToChat = payload?.response.blogs; + } + }, + [searchForChat.rejected]: () => { + + }, + [getChatRoomIdRes.pending]: () => { + + }, + [getChatRoomIdRes.fulfilled]: () => { + /* + console.log('hiiiiiiiiiiiiiiiiiiiiiiii from getChatRoomIdRes'); + if (payload?.meta.status === '200') { + return payload?.response.chat_room_id; + } + return ''; + */ + }, + [getChatRoomIdRes.rejected]: () => { + + }, + [getBlogIdFromBlogUN.pending]: () => { + + }, + [getBlogIdFromBlogUN.fulfilled]: () => { + /* + console.log('hiiiiiiiiiiiiiiiiiiiiiiii from getChatRoomIdRes'); + // const newstate = state; + if (payload?.res.meta.status === '200') { + // if (payload?.isUser) { + // newstate.userbloginfo = payload?.res.response; + // } else { + // newstate.friendbloginfo = payload?.res.response; + // } + return payload?.res.response.id; + } + return ''; + */ + }, + [getBlogIdFromBlogUN.rejected]: () => { + + }, + [setBlogFriendName.pending]: () => { + + }, + [setBlogFriendName.fulfilled]: (state, { payload }) => { + console.log('hiiiiiiiiiiiiiiiiiiiiiiii from setBlogFriendName'); + const newstate = state; + if (payload?.meta.status === '200') { + newstate.friendbloginfo = payload?.response; + } + }, + [setBlogFriendName.rejected]: () => { + + }, + }, +}); + +export default chatReducer.reducer; +export const { + addMessage, loadChat, setFeedMessages, + setGifs, setChatBoxesID, newMessagePress, removeChatBoxID, removeAvaterID, + toggleNewMessage, + , + deleteConversation, setChats, removeChatBoxIDOnly, chatUpdate, newMessagePressRes, +} = chatReducer.actions; diff --git a/tumblr-replica/.history/src/slices/chatmodule/chatmoduleSlice_20211230232308.js b/tumblr-replica/.history/src/slices/chatmodule/chatmoduleSlice_20211230232308.js new file mode 100644 index 00000000..f74a8c6a --- /dev/null +++ b/tumblr-replica/.history/src/slices/chatmodule/chatmoduleSlice_20211230232308.js @@ -0,0 +1,323 @@ +import { createSlice } from '@reduxjs/toolkit'; +import { + getChatFeed, getAllChats, searchForChat, getChatRoomIdRes, getBlogIdFromBlogUN, setBlogFriendName, + sendMessage, chatSearch, recentlyFollowed, uploadPhoto, getAllGifs, deleteMessages, getChatRoomId, +} from './chatmoduleAPI'; +import { MOCK, SERVICETYPE } from '../../apis/globalAPI'; + +const initialState = { + gifs: [], + chatbox: [], + chats: [], + avatars: [], + chatfeed: [], + newmessage: false, + Isloading: false, + newmessagepress: false, + recentlyfollowed: [], + newmessagepressres: false, + chatroomid: '', + blogsToChat: [], + userbloginfo: '', + friendbloginfo: '', +}; + +const chatReducer = createSlice({ + name: 'Chat', + initialState, + reducers: { + setFeedMessages: (state, action) => { + const newstate = state; + newstate.messages = action.payload.messages; + }, + setGifs: (state, action) => { + const newstate = state; + newstate.gifs = action.payload.gifs; + }, + setChatBoxesID: (state, { payload }) => { + if (state.chatbox.length) { + console.log(state.chatbox.length); + const newstate = state; + newstate.avatars.push(state.chatbox[0]); + newstate.chatbox = []; + console.log('set chat boxeses id entered'); + } + state.chatbox.push(payload); + }, + newMessagePress: (state) => { + const newstate = state; + newstate.newmessagepress = !state.newmessagepress; + }, + newMessagePressRes: (state) => { + const newstate = state; + newstate.newmessagepressres = !state.newmessagepressres; + console.log(newstate.newmessagepressres); + }, + removeChatBoxID: (state) => { + const newstate = state; + newstate.avatars.push(newstate.chatbox[0]); + newstate.chatbox = []; + // newstate.avatars.push(action.payload); + }, + removeChatBoxIDOnly: (state) => { + const newstate = state; + newstate.chatbox = []; + }, + removeAvaterID: (state, { payload }) => { + const newstate = state; + const newAvaters = state.avatars.filter((elem) => elem.res.response.chat_room_id + !== payload?.res.response.chat_room_id); + console.log(newAvaters); + newstate.avatars = newAvaters; + if (state.chatbox.length) { + console.log(state.chatbox.length); + newstate.avatars.push(state.chatbox[0]); + newstate.chatbox = []; + } + newstate.chatbox.push(payload); + }, + toggleNewMessage: (state) => { + const newstate = state; + newstate.newmessage = !state.newmessage; + }, + chatUpdate: (state, { payload }) => { + const newstate = state; + const pay = { + text: payload.text, + photo: payload.photo, + gif: payload.gif, + read: payload.read, + blog_username: payload.from_blog_username, + from_blog_id: payload.from_blog_id, + blog_avatar: payload.from_blog_avatar, + blog_avatar_shape: payload.from_blog_avatar_shape, + blog_title: payload.blog_title, + }; + newstate.chatfeed.push(pay); + }, + filterBlogsChat: (state, { payload }) => { + const newstate = state; + console.log(newstate.blogsToChat); + const newFilter = newstate.blogsToChat.filter( + (value) => value?.friend_username.toLowerCase().includes(payload.toLowerCase()), + ); + newstate.blogsToChat = newFilter; + if (payload.length === 0) { + newstate.blogsToChat = []; + } + }, + }, + extraReducers: { + [getAllChats.pending]: () => { + console.log('pendddddd'); + console.log(initialState); + }, + [getAllChats.fulfilled]: (state, { payload }) => { + const newstate = state; + console.log('Get all chats is done'); + if (payload?.meta.status === '200') { + newstate.chats = payload?.response.chat_messages; + } + }, + [getAllChats.rejected]: () => { + console.log('pendddddd'); + }, + [getChatFeed.pending]: () => { + + }, + [getChatFeed.fulfilled]: (state, { payload }) => { + const newstate = state; + if (payload?.meta.status === '200') { + newstate.chatfeed = payload?.response.chat_messages; + console.log('chat feed is got suc '); + } + }, + [getChatFeed.rejected]: () => { + + }, + [sendMessage.pending]: () => { + + }, + [sendMessage.fulfilled]: (state, { payload }) => { + console.log(payload); + if (SERVICETYPE === MOCK) { + const newstate = state; + newstate.chatfeed.push(payload?.messageBody); + } else { + const newstate = state; + if (payload?.res.meta.status === '200') { + console.log(payload?.messageBody); + newstate.chatfeed.push(payload?.messageBody); + console.log('chat feed is got suc '); + } + } + }, + [sendMessage.rejected]: () => { + + }, + [chatSearch.pending]: () => { + + }, + [chatSearch.fulfilled]: (state, action) => { + const newstate = state; + newstate.chats = action.payload; + console.log('Chat list to resp '); + console.log(newstate.chats); + }, + [chatSearch.rejected]: () => { + + }, + [recentlyFollowed.pending]: () => { + + }, + [recentlyFollowed.fulfilled]: (state, { payload }) => { + if (SERVICETYPE !== MOCK) { + console.log(payload); + const newstate = state; + if (payload?.meta.status === '200') { + newstate.recentlyfollowed = payload?.response.followings; + console.log(`payload ${payload?.response.followings}`); + console.log(newstate.recentlyfollowed); + } + } else { + console.log(payload); + const newstate = state; + if (payload?.meta.status === '200') { + newstate.recentlyfollowed = payload?.response.chat_messages; + } + } + }, + [recentlyFollowed.rejected]: () => { + + }, + [uploadPhoto.pending]: () => { + + }, + [uploadPhoto.fulfilled]: (state, action) => { + const newstate = state; + newstate.chats = action.payload; + console.log('Chat list to resp '); + console.log(newstate.chats); + }, + [uploadPhoto.rejected]: () => { + + }, + [getAllGifs.pending]: () => { + + }, + [getAllGifs.fulfilled]: (state, action) => { + const newstate = state; + newstate.chats = action.payload; + console.log('Chat list to resp '); + console.log(newstate.chats); + }, + [getAllGifs.rejected]: () => { + + }, + [deleteMessages.pending]: () => { + + }, + [deleteMessages.fulfilled]: (state, { payload }) => { + const newstate = state; + if (payload?.meta.status === '200') { + console.log('conversation deleted suc'); + newstate.chatfeed = []; + } + }, + [deleteMessages.rejected]: () => { + + }, + [getChatRoomId.pending]: () => { + + }, + [getChatRoomId.fulfilled]: (state, { payload }) => { + const newstate = state; + if (payload?.res.meta.status === '200') { + newstate.chatroomid = payload?.res.response.chat_room_id; + console.log(`chat room id is ${newstate.chatroomid}`); + if (state.chatbox.length) { + console.log(state.chatbox.length); + newstate.avatars.push(state.chatbox[0]); + newstate.chatbox = []; + console.log('set chat boxeses id entered'); + } + state.chatbox.push(payload); + console.log(payload); + } + }, + [getChatRoomId.rejected]: () => { + + }, + [searchForChat.pending]: () => { + + }, + [searchForChat.fulfilled]: (state, { payload }) => { + console.log('hiiiiiiiiiiiiiiiiiiiiiiii'); + console.log(payload); + const newstate = state; + if (payload?.meta.status === '200') { + newstate.blogsToChat = payload?.response.blogs; + } + }, + [searchForChat.rejected]: () => { + + }, + [getChatRoomIdRes.pending]: () => { + + }, + [getChatRoomIdRes.fulfilled]: () => { + /* + console.log('hiiiiiiiiiiiiiiiiiiiiiiii from getChatRoomIdRes'); + if (payload?.meta.status === '200') { + return payload?.response.chat_room_id; + } + return ''; + */ + }, + [getChatRoomIdRes.rejected]: () => { + + }, + [getBlogIdFromBlogUN.pending]: () => { + + }, + [getBlogIdFromBlogUN.fulfilled]: () => { + /* + console.log('hiiiiiiiiiiiiiiiiiiiiiiii from getChatRoomIdRes'); + // const newstate = state; + if (payload?.res.meta.status === '200') { + // if (payload?.isUser) { + // newstate.userbloginfo = payload?.res.response; + // } else { + // newstate.friendbloginfo = payload?.res.response; + // } + return payload?.res.response.id; + } + return ''; + */ + }, + [getBlogIdFromBlogUN.rejected]: () => { + + }, + [setBlogFriendName.pending]: () => { + + }, + [setBlogFriendName.fulfilled]: (state, { payload }) => { + console.log('hiiiiiiiiiiiiiiiiiiiiiiii from setBlogFriendName'); + const newstate = state; + if (payload?.meta.status === '200') { + newstate.friendbloginfo = payload?.response; + } + }, + [setBlogFriendName.rejected]: () => { + + }, + }, +}); + +export default chatReducer.reducer; +export const { + addMessage, loadChat, setFeedMessages, + setGifs, setChatBoxesID, newMessagePress, removeChatBoxID, removeAvaterID, + toggleNewMessage, filterBlogsChat, + deleteConversation, setChats, removeChatBoxIDOnly, chatUpdate, newMessagePressRes, +} = chatReducer.actions; diff --git a/tumblr-replica/src/components/ChatSearchBar/subcomponents/SearchList.jsx b/tumblr-replica/src/components/ChatSearchBar/subcomponents/SearchList.jsx index e21b74a4..80e0ac46 100644 --- a/tumblr-replica/src/components/ChatSearchBar/subcomponents/SearchList.jsx +++ b/tumblr-replica/src/components/ChatSearchBar/subcomponents/SearchList.jsx @@ -43,6 +43,8 @@ function SearchList({ chats }) { } else if ((chatBox.length && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id); dispatch(getChatRoomId({ blogsID: { from_blog_id: User.primaryBlogId, diff --git a/tumblr-replica/src/components/ChatTo/ChatTo.jsx b/tumblr-replica/src/components/ChatTo/ChatTo.jsx index b5b33c44..08071798 100755 --- a/tumblr-replica/src/components/ChatTo/ChatTo.jsx +++ b/tumblr-replica/src/components/ChatTo/ChatTo.jsx @@ -7,6 +7,7 @@ import { Box, ListItem, } from '@material-ui/core'; + import { newMessagePress, } from '../../slices/chatmodule/chatmoduleSlice'; diff --git a/tumblr-replica/src/components/ChatTo/subcomponents/ChatList.jsx b/tumblr-replica/src/components/ChatTo/subcomponents/ChatList.jsx index da44fb60..399691a7 100644 --- a/tumblr-replica/src/components/ChatTo/subcomponents/ChatList.jsx +++ b/tumblr-replica/src/components/ChatTo/subcomponents/ChatList.jsx @@ -42,6 +42,9 @@ function ChatList({ chats }) { } else if ((chatBox.length && chatBox[0].elem.friend_id !== chat.friend_id) || chatBox.length === 0) { + console.log(User.primaryBlogId); + console.log(chat.friend_id, chat.friend_name); + console.log(chat); dispatch(getChatRoomId({ blogsID: { from_blog_id: User.primaryBlogId, diff --git a/tumblr-replica/src/components/FollowingPage/__test__/FollowingPage.test.jsx b/tumblr-replica/src/components/FollowingPage/__test__/FollowingPage.test.jsx new file mode 100644 index 00000000..e69de29b diff --git a/tumblr-replica/src/slices/chatmodule/chatmoduleSlice.js b/tumblr-replica/src/slices/chatmodule/chatmoduleSlice.js index 271a5e30..f74a8c6a 100644 --- a/tumblr-replica/src/slices/chatmodule/chatmoduleSlice.js +++ b/tumblr-replica/src/slices/chatmodule/chatmoduleSlice.js @@ -99,7 +99,7 @@ const chatReducer = createSlice({ const newstate = state; console.log(newstate.blogsToChat); const newFilter = newstate.blogsToChat.filter( - (value) => value.friend_username.toLowerCase().includes(payload.toLowerCase()), + (value) => value?.friend_username.toLowerCase().includes(payload.toLowerCase()), ); newstate.blogsToChat = newFilter; if (payload.length === 0) {