mirror of
https://github.com/cinnyapp/cinny.git
synced 2024-11-20 06:49:52 +01:00
Add function to move space shortcut
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
faaac72b81
commit
a7a5b08ad8
3 changed files with 20 additions and 0 deletions
|
@ -18,6 +18,14 @@ export function deleteSpaceShortcut(roomId) {
|
|||
});
|
||||
}
|
||||
|
||||
export function moveSpaceShortcut(roomId, toIndex) {
|
||||
appDispatcher.dispatch({
|
||||
type: cons.actions.accountData.MOVE_SPACE_SHORTCUTS,
|
||||
roomId,
|
||||
toIndex,
|
||||
});
|
||||
}
|
||||
|
||||
export function categorizeSpace(roomId) {
|
||||
appDispatcher.dispatch({
|
||||
type: cons.actions.accountData.CATEGORIZE_SPACE,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -56,6 +56,7 @@ const cons = {
|
|||
accountData: {
|
||||
CREATE_SPACE_SHORTCUT: 'CREATE_SPACE_SHORTCUT',
|
||||
DELETE_SPACE_SHORTCUT: 'DELETE_SPACE_SHORTCUT',
|
||||
MOVE_SPACE_SHORTCUTS: 'MOVE_SPACE_SHORTCUTS',
|
||||
CATEGORIZE_SPACE: 'CATEGORIZE_SPACE',
|
||||
UNCATEGORIZE_SPACE: 'UNCATEGORIZE_SPACE',
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue