Add function to move space shortcut

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2022-03-08 16:29:52 +05:30
parent faaac72b81
commit a7a5b08ad8
3 changed files with 20 additions and 0 deletions

View file

@ -89,6 +89,17 @@ class AccountData extends EventEmitter {
this._updateSpaceShortcutData([...this.spaceShortcut]);
this.emit(cons.events.accountData.SPACE_SHORTCUT_UPDATED, action.roomId);
},
[cons.actions.accountData.MOVE_SPACE_SHORTCUTS]: () => {
const { roomId, toIndex } = action;
if (!this.spaceShortcut.has(roomId)) return;
this.spaceShortcut.delete(roomId);
const ssList = [...this.spaceShortcut];
if (toIndex >= ssList.length) ssList.push(roomId);
else ssList.splice(toIndex, 0, roomId);
this.spaceShortcut = new Set(ssList);
this._updateSpaceShortcutData(ssList);
this.emit(cons.events.accountData.SPACE_SHORTCUT_UPDATED, roomId);
},
[cons.actions.accountData.CATEGORIZE_SPACE]: () => {
if (this.categorizedSpaces.has(action.roomId)) return;
this.categorizedSpaces.add(action.roomId);