development 3 yıl önce içindeki feature/317_chat_history işlemelerini 1 ile birleştirdi
| @@ -18,10 +18,32 @@ namespace Diligent.WebAPI.Host.Controllers | |||
| _roomService = roomService; | |||
| } | |||
| [HttpGet] | |||
| public async Task<IActionResult> GetAll() | |||
| [Authorize(Roles = "Customer,Support")] | |||
| [HttpGet("rooms-with-filtered-messages")] | |||
| public async Task<ActionResult<List<Room>>> GetAllRoomsWithFilteredMessages(string customerId) | |||
| { | |||
| return Ok(await _roomService.GetRoomsAsync()); | |||
| var rooms = await _roomService.GetRoomsAsync(); | |||
| foreach (var room in rooms) | |||
| { | |||
| List<Message> msg = new(); | |||
| var customer = room.Customers.Where(c => c.CustomerId == customerId).FirstOrDefault(); | |||
| if (customer is not null) | |||
| { | |||
| foreach (var message in room.Messages) | |||
| { | |||
| if (message.CreatedAtUtc >= customer.DateOfEnteringRoom) | |||
| msg.Add(message); | |||
| } | |||
| room.Messages = msg; | |||
| } | |||
| else | |||
| { | |||
| room.Messages = new List<Message>(); | |||
| } | |||
| } | |||
| return rooms; | |||
| } | |||
| [HttpPost] | |||
| @@ -27517,7 +27517,7 @@ | |||
| "@csstools/postcss-stepped-value-functions": "^1.0.0", | |||
| "@csstools/postcss-trigonometric-functions": "^1.0.1", | |||
| "@csstools/postcss-unset-value": "^1.0.1", | |||
| "autoprefixer": "^10.4.7", | |||
| "autoprefixer": "10.4.5", | |||
| "browserslist": "^4.21.0", | |||
| "css-blank-pseudo": "^3.0.3", | |||
| "css-has-pseudo": "^3.0.4", | |||
| @@ -46,7 +46,7 @@ const ChatList = () => { | |||
| }, [user, dispatch, loadedNotification]); | |||
| useEffect(() => { | |||
| dispatch(fetchChatRoomsAsync()); | |||
| (user !== null && dispatch(fetchChatRoomsAsync(user.id))) | |||
| dispatch(fetchRequestsAsync()); | |||
| }, [dispatch]); | |||
| @@ -44,7 +44,7 @@ const MiddleContainer = ({ showTerm }) => { | |||
| }); | |||
| const fulfilled = () => { | |||
| connection.send("Subscribe", user.id); | |||
| connection.send("Subscribe", user && user.id); | |||
| }; | |||
| const rejected = () => {}; | |||
| @@ -6,7 +6,7 @@ axios.defaults.baseURL = apiUrl; | |||
| const responseBody = (response) => response.data; | |||
| const methods = { | |||
| getChats: () => axios.get("/Chat").then(responseBody), | |||
| getChats: (customerId) => axios.get(`/Chat/rooms-with-filtered-messages?customerId=${customerId}`).then(responseBody), | |||
| createChat: (payload) => axios.post("/Chat", payload).then(responseBody), | |||
| }; | |||
| @@ -20,9 +20,9 @@ const initialState = { | |||
| export const fetchChatRoomsAsync = createAsyncThunk( | |||
| "chat/fetchChatRoomsAsync", | |||
| async (_, thunkAPI) => { | |||
| async (payload, thunkAPI) => { | |||
| try { | |||
| return await chatService.getChats(); | |||
| return await chatService.getChats(payload); | |||
| } catch (error) { | |||
| return thunkAPI.rejectWithValue({ error }); | |||
| } | |||
| @@ -194,7 +194,6 @@ const chatSlice = createSlice({ | |||
| }); | |||
| builder.addCase(loadNotifications.fulfilled, (state, action) => { | |||
| state.status = "idle"; | |||
| console.log(action.payload); | |||
| if (action.payload.length === 0) { | |||
| state.notifications = []; | |||
| } else { | |||