How to use the @casual-simulation/aux-common.updateUserSelection function in @casual-simulation/aux-common

To help you get started, we’ve selected a few @casual-simulation/aux-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github casual-simulation / aux / src / aux-vm / managers / SelectionManager.ts View on Github external
private async _selectFileForUser(
        file: AuxObject,
        user: AuxObject,
        multiSelect: boolean
    ) {
        if (SelectionManager._debug) {
            console.log('[SelectionManager] Select File:', file.id);
        }

        const mode = getSelectionMode(user);

        if (mode === 'multi') {
            const { id, newId } = selectionIdForUser(user);
            if (newId) {
                const update = updateUserSelection(newId, file.id);
                await this._helper.updateFile(user, update);
            }
            if (id) {
                const update = toggleFileSelection(file, id, user.id);
                await this._helper.updateFile(file, update);
            }
        } else {
            if (multiSelect) {
                const newId = newSelectionId();
                const current = user.tags['aux._selection'];
                const update = updateUserSelection(newId, file.id);
                await this._helper.updateFile(user, {
                    tags: {
                        ...update.tags,
                        ['aux._selectionMode']: 'multi',
                    },
github casual-simulation / aux / src / aux-vm / managers / SelectionManager.ts View on Github external
private async _clearSelectionForUser(user: AuxObject) {
        if (SelectionManager._debug) {
            console.log('[SelectionManager] Clear selection for', user.id);
        }
        const update = updateUserSelection(null, null);
        await this._helper.updateFile(user, {
            tags: {
                ...update.tags,
                'aux._selectionMode': 'single',
            },
        });
    }
github casual-simulation / aux / src / aux-vm / managers / SelectionManager.ts View on Github external
if (mode === 'multi') {
            const { id, newId } = selectionIdForUser(user);
            if (newId) {
                const update = updateUserSelection(newId, file.id);
                await this._helper.updateFile(user, update);
            }
            if (id) {
                const update = toggleFileSelection(file, id, user.id);
                await this._helper.updateFile(file, update);
            }
        } else {
            if (multiSelect) {
                const newId = newSelectionId();
                const current = user.tags['aux._selection'];
                const update = updateUserSelection(newId, file.id);
                await this._helper.updateFile(user, {
                    tags: {
                        ...update.tags,
                        ['aux._selectionMode']: 'multi',
                    },
                });

                if (current) {
                    const currentFile = this._helper.filesState[current];
                    if (currentFile) {
                        await this._helper.updateFile(currentFile, {
                            tags: {
                                [newId]: true,
                            },
                        });
                    }
github casual-simulation / aux / src / aux-vm / managers / SelectionManager.ts View on Github external
tags: {
                                [newId]: true,
                            },
                        });
                    }
                }

                await this._helper.updateFile(file, {
                    tags: {
                        [newId]: true,
                    },
                });
            } else {
                const selection = file.id;

                const update = updateUserSelection(selection, file.id);
                await this._helper.updateFile(user, update);
                await this._helper.updateFile(file, { tags: {} });
            }
        }

        this._userChangedSelection.next();
    }
}