mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-16 04:00:29 +03:00
Refactor navigation
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
f47998a553
commit
992da7c7be
7 changed files with 130 additions and 55 deletions
19
src/client/event/roomList.js
Normal file
19
src/client/event/roomList.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import cons from '../state/cons';
|
||||
import navigation from '../state/navigation';
|
||||
import { selectTab, selectSpace } from '../action/navigation';
|
||||
|
||||
const listenRoomLeave = (roomId) => {
|
||||
const lRoomIndex = navigation.selectedSpacePath.indexOf(roomId);
|
||||
if (lRoomIndex === -1) return;
|
||||
if (lRoomIndex === 0) selectTab(cons.tabs.HOME);
|
||||
else selectSpace(navigation.selectedSpacePath[lRoomIndex - 1]);
|
||||
};
|
||||
|
||||
function initRoomListListener(roomList) {
|
||||
roomList.on(cons.events.roomList.ROOM_LEAVED, listenRoomLeave);
|
||||
}
|
||||
function removeRoomListListener(roomList) {
|
||||
roomList.removeListener(cons.events.roomList.ROOM_LEAVED, listenRoomLeave);
|
||||
}
|
||||
|
||||
export { initRoomListListener, removeRoomListListener };
|
||||
Loading…
Add table
Add a link
Reference in a new issue