FloatChatReducer.swift 885 B

12345678910111213141516171819202122232425262728
  1. //
  2. // FloatChatReducer.swift
  3. // TUIRoomKit
  4. //
  5. // Created by CY zhao on 2024/5/10.
  6. // Copyright © 2024 Tencent. All rights reserved.
  7. //
  8. import Foundation
  9. import RTCRoomEngine
  10. let floatChatReducer = Reducer<FloatChatState>(
  11. ReduceOn(FloatChatActions.onMessageSended) { state, action in
  12. let selfInfo = TUIRoomEngine.getSelfInfo()
  13. let user = FloatChatUser(loginInfo: selfInfo)
  14. let floatMessage = FloatChatMessage(user: user, content: action.payload)
  15. state.latestMessage = floatMessage
  16. },
  17. ReduceOn(FloatChatActions.onMessageReceived) { state, action in
  18. state.latestMessage = action.payload
  19. },
  20. ReduceOn(FloatViewActions.showFloatInputView) { state, action in
  21. state.isFloatInputViewShow = action.payload
  22. },
  23. ReduceOn(FloatChatActions.setRoomId) { state, action in
  24. state.roomId = action.payload
  25. }
  26. )