Browse Source

fix some bugs need to check camera sendings function

serg1557733 1 year ago
parent
commit
00f345a907

+ 13 - 0
backend/avatars/PrivateMessage.js

@@ -0,0 +1,13 @@
+const {model, Schema} = require('mongoose');
+
+const PrivateMessage = new Schema({
+    text: {type: String, required: true},
+    createDate: {type: Date, required: true},
+    fromUser:{ type: Schema.Types.ObjectId, ref: 'User' },
+    toUser:{ type: Schema.Types.ObjectId, ref: 'User' },
+    file: {type: String} , // not in use
+    fileType: {type: String} //not in use
+
+})
+
+module.exports = model('PrivateMessage', PrivateMessage)

+ 0 - 4
frontend/src/components/chatPage/userInfo/UserInfo.jsx

@@ -35,8 +35,6 @@ export const UserInfo = () => {
     const storeUserAvatar = useSelector(state => state.userDataReducer.avatar)
     const chatId = useSelector(state => state.userDataReducer.chatId)
     const showUserInfoBox = useSelector(state => state.userDataReducer.showUserInfoBox)
-
-
     const newPrivateMessages = useSelector(state => state.getUserSocketReducer.newPrivateMessages)
 
 
@@ -48,8 +46,6 @@ export const UserInfo = () => {
         setDisplayType('none')
     }
 
-    console.log(showUserInfoBox)
-
     // if(socket){
     //     socket.on('my chats', (data)=> console.log('my chats', data))
     // }

+ 2 - 3
frontend/src/components/chatPage/userInfo/userInfo.scss

@@ -24,9 +24,8 @@
 }
 .pcUsersAvatar {
     background-color: grey;
-    width: 100px;
-    height: 100px;
-    font-size: 14;
+    width: 80px !important;
+    height: 80px !important; //need to change in classlist styles
     margin: 20px auto;
     cursor: pointer;
 }

+ 5 - 4
frontend/src/reducers/messageReducer.js

@@ -13,7 +13,8 @@ const initialState = {
     ref: null
 }
 
-const POST_FILES_URL = process.env.REACT_APP_SERVER_URL+`/files`;
+const POST_FILES_URL = `http://localhost:5000/files`;
+
 
 export const sendMessageToSocket = (state, data) => {
              if (!!state.message && state.message.length < 200) {    //remove to other file
@@ -55,8 +56,8 @@ export const fileMessage = createAsyncThunk(
         const token = localStorage.getItem('token')
         try {
             const formData = new FormData();
-            if(files.length) {
-                 for (let i = 0; i < files.length; i++) {
+            if(files?.length) {
+                 for (let i = 0; i < files?.length; i++) {
                 formData.append('files', files[i])
                 }
             } else {
@@ -97,7 +98,7 @@ const messageReducerSlice = createSlice({
     extraReducers: (bilder) => {
     bilder
     .addCase(fileMessage.fulfilled, (state, action) => {
-        console.log('send', action)
+        console.log(action.payload)
         state.files = action.payload.data?.files
             
     })