From 4ab2af51a58eb58c0105709e63c4f44533feec61 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Sun, 6 Mar 2022 17:51:21 +0530 Subject: [PATCH] Add option to create muliple pin spaces shortcut Signed-off-by: Ajay Bura --- src/client/action/accountData.js | 3 +++ src/client/state/AccountData.js | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) 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); },