UserReducer.swift 977 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // UserReducer.swift
  3. // TUIRoomKit
  4. //
  5. // Created by CY zhao on 2024/6/5.
  6. //
  7. import RTCRoomEngine
  8. import TUICore
  9. let userReducer = Reducer<UserState>(
  10. ReduceOn(UserActions.getSelfInfo, reduce: { state, action in
  11. var selfInfo = UserInfo()
  12. selfInfo.userId = TUILogin.getUserID() ?? ""
  13. selfInfo.userName = TUILogin.getNickName() ?? ""
  14. selfInfo.avatarUrl = TUILogin.getFaceUrl() ?? ""
  15. state.selfInfo = selfInfo
  16. }),
  17. ReduceOn(UserActions.updateSelfInfo, reduce: { state, action in
  18. state.selfInfo = action.payload
  19. }),
  20. ReduceOn(UserActions.updateAllUsers, reduce: { state, action in
  21. state.allUsers = action.payload
  22. }),
  23. ReduceOn(UserActions.updateHasScreenStreamUsers, reduce: { state, action in
  24. state.hasScreenStreamUsers = action.payload
  25. }),
  26. ReduceOn(UserActions.updateDisableMessageUsers, reduce: { state, action in
  27. state.disableMessageUsers = action.payload
  28. })
  29. )