Add option to create muliple pin spaces shortcut
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
9ffc4eaa40
commit
4ab2af51a5
2 changed files with 12 additions and 2 deletions
|
@ -1,6 +1,9 @@
|
||||||
import appDispatcher from '../dispatcher';
|
import appDispatcher from '../dispatcher';
|
||||||
import cons from '../state/cons';
|
import cons from '../state/cons';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string | string[]} roomId - room id or array of them to add into shortcuts
|
||||||
|
*/
|
||||||
export function createSpaceShortcut(roomId) {
|
export function createSpaceShortcut(roomId) {
|
||||||
appDispatcher.dispatch({
|
appDispatcher.dispatch({
|
||||||
type: cons.actions.accountData.CREATE_SPACE_SHORTCUT,
|
type: cons.actions.accountData.CREATE_SPACE_SHORTCUT,
|
||||||
|
|
|
@ -71,8 +71,15 @@ class AccountData extends EventEmitter {
|
||||||
accountActions(action) {
|
accountActions(action) {
|
||||||
const actions = {
|
const actions = {
|
||||||
[cons.actions.accountData.CREATE_SPACE_SHORTCUT]: () => {
|
[cons.actions.accountData.CREATE_SPACE_SHORTCUT]: () => {
|
||||||
if (this.spaceShortcut.has(action.roomId)) return;
|
const addRoomId = (id) => {
|
||||||
this.spaceShortcut.add(action.roomId);
|
if (this.spaceShortcut.has(id)) return;
|
||||||
|
this.spaceShortcut.add(id);
|
||||||
|
};
|
||||||
|
if (Array.isArray(action.roomId)) {
|
||||||
|
action.roomId.forEach(addRoomId);
|
||||||
|
} else {
|
||||||
|
addRoomId(action.roomId);
|
||||||
|
}
|
||||||
this._updateSpaceShortcutData([...this.spaceShortcut]);
|
this._updateSpaceShortcutData([...this.spaceShortcut]);
|
||||||
this.emit(cons.events.accountData.SPACE_SHORTCUT_UPDATED, action.roomId);
|
this.emit(cons.events.accountData.SPACE_SHORTCUT_UPDATED, action.roomId);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue