Add option to create muliple pin spaces shortcut
authorAjay Bura <ajbura@gmail.com>
Sun, 6 Mar 2022 12:21:21 +0000 (17:51 +0530)
committerAjay Bura <ajbura@gmail.com>
Sun, 6 Mar 2022 12:21:21 +0000 (17:51 +0530)
Signed-off-by: Ajay Bura <ajbura@gmail.com>
src/client/action/accountData.js
src/client/state/AccountData.js

index 4d2d2e5c67e94e8d140b4617a80895b6d8153bbd..cb7a9b4695451d85224d66ab67656869e0c07a60 100644 (file)
@@ -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,
index f20c20e58c9ea9163a1841b32444b67ac66c9ab9..8ac6ae008279fb03a85f50dd1c98df518da8dbbc 100644 (file)
@@ -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);
       },