()
| 7 | * 获取 redux action |
| 8 | */ |
| 9 | export default function useAction() { |
| 10 | const dispatch = useDispatch(); |
| 11 | |
| 12 | return { |
| 13 | setUser(user: User) { |
| 14 | dispatch({ |
| 15 | type: ActionTypes.SetUser, |
| 16 | payload: user, |
| 17 | }); |
| 18 | }, |
| 19 | |
| 20 | logout() { |
| 21 | dispatch({ |
| 22 | type: ActionTypes.Logout, |
| 23 | }); |
| 24 | }, |
| 25 | |
| 26 | setAvatar(avatar: string) { |
| 27 | dispatch({ |
| 28 | type: ActionTypes.SetAvatar, |
| 29 | payload: avatar, |
| 30 | }); |
| 31 | }, |
| 32 | |
| 33 | setFocus(linkmanId: string) { |
| 34 | dispatch({ |
| 35 | type: ActionTypes.SetFocus, |
| 36 | payload: linkmanId, |
| 37 | }); |
| 38 | }, |
| 39 | |
| 40 | addLinkman(linkman: Linkman, focus = false) { |
| 41 | dispatch({ |
| 42 | type: ActionTypes.AddLinkman, |
| 43 | payload: { |
| 44 | linkman, |
| 45 | focus, |
| 46 | }, |
| 47 | }); |
| 48 | }, |
| 49 | |
| 50 | removeLinkman(linkmanId: string) { |
| 51 | dispatch({ |
| 52 | type: ActionTypes.RemoveLinkman, |
| 53 | payload: linkmanId, |
| 54 | }); |
| 55 | }, |
| 56 | |
| 57 | addLinkmanHistoryMessages(linkmanId: string, messages: Message[]) { |
| 58 | messages.forEach((message) => convertMessage(message)); |
| 59 | dispatch({ |
| 60 | type: ActionTypes.AddLinkmanHistoryMessages, |
| 61 | payload: { |
| 62 | linkmanId, |
| 63 | messages, |
| 64 | }, |
| 65 | }); |
| 66 | }, |
no outgoing calls
no test coverage detected