mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-13 18:50:29 +03:00
Add RoomSettings comp
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
8eda0aeab3
commit
5777c1ab27
20 changed files with 306 additions and 25 deletions
|
|
@ -23,6 +23,13 @@ export function selectRoom(roomId, eventId) {
|
|||
});
|
||||
}
|
||||
|
||||
export function toggleRoomSettings(roomId) {
|
||||
appDispatcher.dispatch({
|
||||
type: cons.actions.navigation.TOGGLE_ROOM_SETTINGS,
|
||||
roomId,
|
||||
});
|
||||
}
|
||||
|
||||
export function openInviteList() {
|
||||
appDispatcher.dispatch({
|
||||
type: cons.actions.navigation.OPEN_INVITE_LIST,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { openSearch } from '../action/navigation';
|
||||
import { openSearch, toggleRoomSettings } from '../action/navigation';
|
||||
import navigation from '../state/navigation';
|
||||
|
||||
function listenKeyboard(event) {
|
||||
|
|
@ -11,12 +11,24 @@ function listenKeyboard(event) {
|
|||
openSearch();
|
||||
}
|
||||
}
|
||||
|
||||
if (!event.ctrlKey && !event.altKey) {
|
||||
if (event.keyCode === 38 && navigation.isRoomSettings) {
|
||||
// close room settings
|
||||
toggleRoomSettings();
|
||||
return;
|
||||
}
|
||||
if (event.keyCode === 40 && !navigation.isRoomSettings) {
|
||||
// open room settings
|
||||
toggleRoomSettings();
|
||||
return;
|
||||
}
|
||||
|
||||
if (navigation.isRawModalVisible) return;
|
||||
if (['text', 'textarea'].includes(document.activeElement.type)) {
|
||||
return;
|
||||
}
|
||||
if (event.keyCode < 48
|
||||
if ((event.keyCode !== 8 && event.keyCode < 48)
|
||||
|| (event.keyCode >= 91 && event.keyCode <= 93)
|
||||
|| (event.keyCode >= 112 && event.keyCode <= 183)) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ const cons = {
|
|||
SELECT_TAB: 'SELECT_TAB',
|
||||
SELECT_SPACE: 'SELECT_SPACE',
|
||||
SELECT_ROOM: 'SELECT_ROOM',
|
||||
TOGGLE_PEOPLE_DRAWER: 'TOGGLE_PEOPLE_DRAWER',
|
||||
TOGGLE_ROOM_SETTINGS: 'TOGGLE_ROOM_SETTINGS',
|
||||
OPEN_INVITE_LIST: 'OPEN_INVITE_LIST',
|
||||
OPEN_PUBLIC_ROOMS: 'OPEN_PUBLIC_ROOMS',
|
||||
OPEN_CREATE_ROOM: 'OPEN_CREATE_ROOM',
|
||||
|
|
@ -65,7 +65,7 @@ const cons = {
|
|||
TAB_SELECTED: 'TAB_SELECTED',
|
||||
SPACE_SELECTED: 'SPACE_SELECTED',
|
||||
ROOM_SELECTED: 'ROOM_SELECTED',
|
||||
PEOPLE_DRAWER_TOGGLED: 'PEOPLE_DRAWER_TOGGLED',
|
||||
ROOM_SETTINGS_TOGGLED: 'ROOM_SETTINGS_TOGGLED',
|
||||
INVITE_LIST_OPENED: 'INVITE_LIST_OPENED',
|
||||
PUBLIC_ROOMS_OPENED: 'PUBLIC_ROOMS_OPENED',
|
||||
CREATE_ROOM_OPENED: 'CREATE_ROOM_OPENED',
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ class Navigation extends EventEmitter {
|
|||
this.selectedSpacePath = [cons.tabs.HOME];
|
||||
|
||||
this.selectedRoomId = null;
|
||||
this.isRoomSettings = false;
|
||||
this.recentRooms = [];
|
||||
|
||||
this.isRawModalVisible = false;
|
||||
|
|
@ -77,6 +78,10 @@ class Navigation extends EventEmitter {
|
|||
this.removeRecentRoom(prevSelectedRoomId);
|
||||
this.addRecentRoom(prevSelectedRoomId);
|
||||
this.removeRecentRoom(this.selectedRoomId);
|
||||
if (this.isRoomSettings) {
|
||||
this.isRoomSettings = !this.isRoomSettings;
|
||||
this.emit(cons.events.navigation.ROOM_SETTINGS_TOGGLED, this.isRoomSettings);
|
||||
}
|
||||
this.emit(
|
||||
cons.events.navigation.ROOM_SELECTED,
|
||||
this.selectedRoomId,
|
||||
|
|
@ -84,6 +89,10 @@ class Navigation extends EventEmitter {
|
|||
action.eventId,
|
||||
);
|
||||
},
|
||||
[cons.actions.navigation.TOGGLE_ROOM_SETTINGS]: () => {
|
||||
this.isRoomSettings = !this.isRoomSettings;
|
||||
this.emit(cons.events.navigation.ROOM_SETTINGS_TOGGLED, this.isRoomSettings);
|
||||
},
|
||||
[cons.actions.navigation.OPEN_INVITE_LIST]: () => {
|
||||
this.emit(cons.events.navigation.INVITE_LIST_OPENED);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue