import appDispatcher from '../dispatcher';
import cons from '../state/cons';
-function selectTab(tabId) {
+export function selectTab(tabId) {
appDispatcher.dispatch({
type: cons.actions.navigation.SELECT_TAB,
tabId,
});
}
-function selectSpace(roomId) {
+export function selectSpace(roomId) {
appDispatcher.dispatch({
type: cons.actions.navigation.SELECT_SPACE,
roomId,
});
}
-function selectRoom(roomId, eventId) {
+export function selectRoom(roomId, eventId) {
appDispatcher.dispatch({
type: cons.actions.navigation.SELECT_ROOM,
roomId,
});
}
-function openInviteList() {
+export function openInviteList() {
appDispatcher.dispatch({
type: cons.actions.navigation.OPEN_INVITE_LIST,
});
}
-function openPublicRooms(searchTerm) {
+export function openPublicRooms(searchTerm) {
appDispatcher.dispatch({
type: cons.actions.navigation.OPEN_PUBLIC_ROOMS,
searchTerm,
});
}
-function openCreateRoom() {
+export function openCreateRoom() {
appDispatcher.dispatch({
type: cons.actions.navigation.OPEN_CREATE_ROOM,
});
}
-function openInviteUser(roomId, searchTerm) {
+export function openInviteUser(roomId, searchTerm) {
appDispatcher.dispatch({
type: cons.actions.navigation.OPEN_INVITE_USER,
roomId,
});
}
-function openProfileViewer(userId, roomId) {
+export function openProfileViewer(userId, roomId) {
appDispatcher.dispatch({
type: cons.actions.navigation.OPEN_PROFILE_VIEWER,
userId,
});
}
-function openSettings() {
+export function openSettings() {
appDispatcher.dispatch({
type: cons.actions.navigation.OPEN_SETTINGS,
});
}
-function openEmojiBoard(cords, requestEmojiCallback) {
+export function openEmojiBoard(cords, requestEmojiCallback) {
appDispatcher.dispatch({
type: cons.actions.navigation.OPEN_EMOJIBOARD,
cords,
});
}
-function openReadReceipts(roomId, userIds) {
+export function openReadReceipts(roomId, userIds) {
appDispatcher.dispatch({
type: cons.actions.navigation.OPEN_READRECEIPTS,
roomId,
});
}
-function openRoomOptions(cords, roomId) {
+export function openRoomOptions(cords, roomId) {
appDispatcher.dispatch({
type: cons.actions.navigation.OPEN_ROOMOPTIONS,
cords,
});
}
-function replyTo(userId, eventId, body) {
+export function replyTo(userId, eventId, body) {
appDispatcher.dispatch({
type: cons.actions.navigation.CLICK_REPLY_TO,
userId,
});
}
-function openSearch(term) {
+export function openSearch(term) {
appDispatcher.dispatch({
type: cons.actions.navigation.OPEN_SEARCH,
term,
});
}
-
-export {
- selectTab,
- selectSpace,
- selectRoom,
- openInviteList,
- openPublicRooms,
- openCreateRoom,
- openInviteUser,
- openProfileViewer,
- openSettings,
- openEmojiBoard,
- openReadReceipts,
- openRoomOptions,
- replyTo,
- openSearch,
-};
--- /dev/null
+import { openSearch } from '../action/navigation';
+import navigation from '../state/navigation';
+
+function listenKeyboard(event) {
+ // Ctrl +
+ if (event.ctrlKey) {
+ // k - for search Modal
+ if (event.keyCode === 75) {
+ if (navigation.isRawModalVisible) return;
+ event.preventDefault();
+ openSearch();
+ }
+ }
+}
+
+function initHotkeys() {
+ document.body.addEventListener('keydown', listenKeyboard);
+}
+
+function removeHotkeys() {
+ document.body.removeEventListener('keydown', listenKeyboard);
+}
+
+export { initHotkeys, removeHotkeys };
this.selectedRoomId = null;
this.recentRooms = [];
+
+ this.isRawModalVisible = false;
}
_setSpacePath(roomId) {
addRecentRoom(roomId) {
if (typeof roomId !== 'string') return;
- this.removeRecentRoom(roomId);
this.recentRooms.push(roomId);
if (this.recentRooms.length > 10) {
this.recentRooms.splice(0, 1);
}
}
+ setIsRawModalVisible(visible) {
+ this.isRawModalVisible = visible;
+ }
+
navigate(action) {
const actions = {
[cons.actions.navigation.SELECT_TAB]: () => {
[cons.actions.navigation.SELECT_ROOM]: () => {
const prevSelectedRoomId = this.selectedRoomId;
this.selectedRoomId = action.roomId;
+ this.removeRecentRoom(prevSelectedRoomId);
this.addRecentRoom(prevSelectedRoomId);
this.removeRecentRoom(this.selectedRoomId);
this.emit(