diff --git a/src/client/action/accountData.js b/src/client/action/accountData.js index 4d2d2e5..cb7a9b4 100644 --- a/src/client/action/accountData.js +++ b/src/client/action/accountData.js @@ -1,6 +1,9 @@ import appDispatcher from '../dispatcher'; import cons from '../state/cons'; +/** + * @param {string | string[]} roomId - room id or array of them to add into shortcuts + */ export function createSpaceShortcut(roomId) { appDispatcher.dispatch({ type: cons.actions.accountData.CREATE_SPACE_SHORTCUT, diff --git a/src/client/state/AccountData.js b/src/client/state/AccountData.js index f20c20e..8ac6ae0 100644 --- a/src/client/state/AccountData.js +++ b/src/client/state/AccountData.js @@ -71,8 +71,15 @@ class AccountData extends EventEmitter { accountActions(action) { const actions = { [cons.actions.accountData.CREATE_SPACE_SHORTCUT]: () => { - if (this.spaceShortcut.has(action.roomId)) return; - this.spaceShortcut.add(action.roomId); + const addRoomId = (id) => { + 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.emit(cons.events.accountData.SPACE_SHORTCUT_UPDATED, action.roomId); },