Add option to create muliple pin spaces shortcut

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2022-03-06 17:51:21 +05:30
parent 9ffc4eaa40
commit 4ab2af51a5
2 changed files with 12 additions and 2 deletions

View 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,

View 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);
},