TSK-685: prioritise selection when focus exists (#2648)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2023-02-16 21:09:34 +05:00 committed by GitHub
parent acc5e124a1
commit 463c0a692a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,10 +34,10 @@ import { FocusSelection } from './selection'
*/
export function getSelection (focusStore: FocusSelection, selectionStore: Doc[]): Doc[] {
let docs: Doc[] = []
if (selectionStore.find((it) => it._id === focusStore.focus?._id) === undefined && focusStore.focus !== undefined) {
docs = [focusStore.focus]
} else {
if (selectionStore.length > 0) {
docs = selectionStore
} else if (focusStore.focus !== undefined) {
docs = [focusStore.focus]
}
return docs
}
@ -46,9 +46,9 @@ export function getSelection (focusStore: FocusSelection, selectionStore: Doc[])
* @public
*
* Find all action contributions applicable for specified _class.
* If derivedFrom is specifie, only actions applicable to derivedFrom class will be used.
* If derivedFrom is specified, only actions applicable to derivedFrom class will be used.
* So if we have contribution for Doc, Space and we ask for SpaceWithStates and derivedFrom=Space,
* we won't recieve Doc contribution but recieve Space ones.
* we won't receive Doc contribution but receive Space ones.
*/
export async function getActions (
client: Client,