Added space nesting (#52)
This commit is contained in:
@@ -6,29 +6,44 @@ class Navigation extends EventEmitter {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.activeTab = 'home';
|
||||
this.activeRoomId = null;
|
||||
this.selectedTab = 'home';
|
||||
this.selectedSpaceId = null;
|
||||
this.selectedSpacePath = [];
|
||||
this.selectedRoomId = null;
|
||||
this.isPeopleDrawerVisible = true;
|
||||
|
||||
// TODO:
|
||||
window.navigation = this;
|
||||
}
|
||||
|
||||
getActiveTab() {
|
||||
return this.activeTab;
|
||||
}
|
||||
|
||||
getActiveRoomId() {
|
||||
return this.activeRoomId;
|
||||
_setSpacePath(roomId) {
|
||||
if (roomId === null) {
|
||||
this.selectedSpacePath = [];
|
||||
return;
|
||||
}
|
||||
if (this.selectedSpacePath.includes(roomId)) {
|
||||
const spIndex = this.selectedSpacePath.indexOf(roomId);
|
||||
this.selectedSpacePath = this.selectedSpacePath.slice(0, spIndex + 1);
|
||||
return;
|
||||
}
|
||||
this.selectedSpacePath.push(roomId);
|
||||
}
|
||||
|
||||
navigate(action) {
|
||||
const actions = {
|
||||
[cons.actions.navigation.CHANGE_TAB]: () => {
|
||||
this.activeTab = action.tabId;
|
||||
this.emit(cons.events.navigation.TAB_CHANGED, this.activeTab);
|
||||
this.selectedTab = action.tabId;
|
||||
this.emit(cons.events.navigation.TAB_CHANGED, this.selectedTab);
|
||||
},
|
||||
[cons.actions.navigation.SELECT_SPACE]: () => {
|
||||
this._setSpacePath(action.roomId);
|
||||
this.selectedSpaceId = action.roomId;
|
||||
this.emit(cons.events.navigation.SPACE_SELECTED, action.roomId);
|
||||
},
|
||||
[cons.actions.navigation.SELECT_ROOM]: () => {
|
||||
const prevActiveRoomId = this.activeRoomId;
|
||||
this.activeRoomId = action.roomId;
|
||||
this.emit(cons.events.navigation.ROOM_SELECTED, this.activeRoomId, prevActiveRoomId);
|
||||
const prevSelectedRoomId = this.selectedRoomId;
|
||||
this.selectedRoomId = action.roomId;
|
||||
this.emit(cons.events.navigation.ROOM_SELECTED, this.selectedRoomId, prevSelectedRoomId);
|
||||
},
|
||||
[cons.actions.navigation.TOGGLE_PEOPLE_DRAWER]: () => {
|
||||
this.isPeopleDrawerVisible = !this.isPeopleDrawerVisible;
|
||||
|
||||
Reference in New Issue
Block a user