mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-14 11:10: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 };
|
||||
|
|
@ -7,6 +7,7 @@ import RoomList from './state/RoomList';
|
|||
import RoomsInput from './state/RoomsInput';
|
||||
import Notifications from './state/Notifications';
|
||||
import { initHotkeys } from './event/hotkeys';
|
||||
import { initRoomListListener } from './event/roomList';
|
||||
|
||||
global.Olm = require('@matrix-org/olm');
|
||||
|
||||
|
|
@ -64,6 +65,7 @@ class InitMatrix extends EventEmitter {
|
|||
this.roomsInput = new RoomsInput(this.matrixClient);
|
||||
this.notifications = new Notifications(this.roomList);
|
||||
initHotkeys();
|
||||
initRoomListListener(this.roomList);
|
||||
this.emit('init_loading_finished');
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue