From 9efc432e160b429a0643c38e28140bcf42af30a7 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Thu, 28 Jun 2018 13:45:27 +0200 Subject: Add history to redux thunk --- src/client/react/store/actions.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/client/react/store/actions.js (limited to 'src/client/react/store/actions.js') diff --git a/src/client/react/store/actions.js b/src/client/react/store/actions.js new file mode 100644 index 0000000..c4cc9ba --- /dev/null +++ b/src/client/react/store/actions.js @@ -0,0 +1,14 @@ +import users from '../users'; + +export function showRoomFinder() { + return (dispatch, getState, getHistory) => { + const { user, setUser } = getHistory(); + + if (user == null || users.byId[user].type !== 'r') { + // We are not currently viewing a room, correct the situation. + setUser(users.allRoomIds[0]); + } + + dispatch({ type: 'ROOM_FINDER/SHOW' }); + }; +} -- cgit v1.1