Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
frontend
Commits
a5c9560b
Commit
a5c9560b
authored
11 months ago
by
Adrian Orłów
Browse files
Options
Downloads
Patches
Plain Diff
feat: partial fix dependency cycle
parent
17f09e86
No related branches found
No related tags found
2 merge requests
!223
reset the pin numbers before search results are fetch (so the results will be...
,
!156
feat: publications modal elements links + reaction search (MIN-241, MIN-229)
Pipeline
#87849
failed
11 months ago
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/redux/bioEntity/thunks/getMultiBioEntity.ts
+7
-36
7 additions, 36 deletions
src/redux/bioEntity/thunks/getMultiBioEntity.ts
src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts
+45
-0
45 additions, 0 deletions
...Entity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts
with
52 additions
and
36 deletions
src/redux/bioEntity/thunks/getMultiBioEntity.ts
+
7
−
36
View file @
a5c9560b
import
{
getBioEntitiesIdsFromReaction
}
from
'
@/components/Map/MapViewer/utils/listeners/mapSingleClick/getBioEntitiesIdsFromReaction
'
;
import
{
SIZE_OF_EMPTY_ARRAY
,
ZERO
}
from
'
@/constants/common
'
;
import
{
selectTab
}
from
'
@/redux/drawer/drawer.slice
'
;
import
{
getReactionsByIds
}
from
'
@/redux/reactions/reactions.thunks
'
;
import
{
BioEntityContent
}
from
'
@/types/models
'
;
import
{
BioEntityContent
}
from
'
@/types/models
'
;
import
{
PerfectMultiSearchParams
}
from
'
@/types/search
'
;
import
{
PerfectMultiSearchParams
}
from
'
@/types/search
'
;
import
{
ThunkConfig
}
from
'
@/types/store
'
;
import
{
ThunkConfig
}
from
'
@/types/store
'
;
...
@@ -9,7 +5,8 @@ import { getErrorMessage } from '@/utils/getErrorMessage';
...
@@ -9,7 +5,8 @@ import { getErrorMessage } from '@/utils/getErrorMessage';
import
{
PayloadAction
,
createAsyncThunk
}
from
'
@reduxjs/toolkit
'
;
import
{
PayloadAction
,
createAsyncThunk
}
from
'
@reduxjs/toolkit
'
;
import
{
addNumbersToEntityNumberData
}
from
'
../../entityNumber/entityNumber.slice
'
;
import
{
addNumbersToEntityNumberData
}
from
'
../../entityNumber/entityNumber.slice
'
;
import
{
MULTI_BIO_ENTITY_FETCHING_ERROR_PREFIX
}
from
'
../bioEntity.constants
'
;
import
{
MULTI_BIO_ENTITY_FETCHING_ERROR_PREFIX
}
from
'
../bioEntity.constants
'
;
import
{
getBioEntity
}
from
'
../bioEntity.thunks
'
;
import
{
getBioEntity
}
from
'
./getBioEntity
'
;
import
{
fetchReactionsAndGetBioEntitiesIds
}
from
'
./utils/fetchReactionsAndGetBioEntitiesIds
'
;
type
GetMultiBioEntityProps
=
PerfectMultiSearchParams
;
type
GetMultiBioEntityProps
=
PerfectMultiSearchParams
;
type
GetMultiBioEntityActions
=
PayloadAction
<
BioEntityContent
[]
|
undefined
|
string
>
[];
// if error thrown, string containing error message is returned
type
GetMultiBioEntityActions
=
PayloadAction
<
BioEntityContent
[]
|
undefined
|
string
>
[];
// if error thrown, string containing error message is returned
...
@@ -40,37 +37,11 @@ export const getMultiBioEntity = createAsyncThunk<
...
@@ -40,37 +37,11 @@ export const getMultiBioEntity = createAsyncThunk<
const
bioEntityIds
=
bioEntityContents
.
map
(
b
=>
b
.
bioEntity
.
elementId
);
const
bioEntityIds
=
bioEntityContents
.
map
(
b
=>
b
.
bioEntity
.
elementId
);
dispatch
(
addNumbersToEntityNumberData
(
bioEntityIds
));
dispatch
(
addNumbersToEntityNumberData
(
bioEntityIds
));
const
bioEntityReactionsIds
=
(
bioEntityContents
||
[])
const
bioEntitiesIds
=
await
fetchReactionsAndGetBioEntitiesIds
({
.
filter
(
c
=>
c
?.
bioEntity
?.
idReaction
)
bioEntityContents
,
.
map
(
c
=>
c
?.
bioEntity
?.
id
)
dispatch
,
.
filter
((
id
):
id
is
number
=>
typeof
id
===
'
number
'
);
});
getMultiBioEntity
({
searchQueries
:
bioEntitiesIds
,
isPerfectMatch
:
true
});
if
(
bioEntityReactionsIds
.
length
>
ZERO
)
{
dispatch
(
getReactionsByIds
({
ids
:
bioEntityReactionsIds
,
shouldConcat
:
true
,
}),
).
then
(
async
result
=>
{
if
(
typeof
result
.
payload
===
'
string
'
)
return
;
const
reactions
=
result
.
payload
?.
data
;
if
(
!
reactions
||
reactions
.
length
===
SIZE_OF_EMPTY_ARRAY
)
return
;
const
bioEntitiesIds
=
reactions
.
map
(
reaction
=>
getBioEntitiesIdsFromReaction
(
reaction
))
.
flat
();
// dispatch(openReactionDrawerById(reactions[FIRST_ARRAY_ELEMENT].id));
dispatch
(
selectTab
(
''
));
await
dispatch
(
getMultiBioEntity
({
searchQueries
:
bioEntitiesIds
,
isPerfectMatch
:
true
,
}),
);
});
}
return
bioEntityContents
;
return
bioEntityContents
;
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
This diff is collapsed.
Click to expand it.
src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts
0 → 100644
+
45
−
0
View file @
a5c9560b
import
{
getBioEntitiesIdsFromReaction
}
from
'
@/components/Map/MapViewer/utils/listeners/mapSingleClick/getBioEntitiesIdsFromReaction
'
;
import
{
SIZE_OF_EMPTY_ARRAY
,
ZERO
}
from
'
@/constants/common
'
;
import
{
selectTab
}
from
'
@/redux/drawer/drawer.slice
'
;
import
{
getReactionsByIds
}
from
'
@/redux/reactions/reactions.thunks
'
;
import
type
{
AppDispatch
}
from
'
@/redux/store
'
;
import
type
{
BioEntityContent
}
from
'
@/types/models
'
;
interface
Args
{
bioEntityContents
:
BioEntityContent
[];
dispatch
:
AppDispatch
;
}
export
const
fetchReactionsAndGetBioEntitiesIds
=
async
({
dispatch
,
bioEntityContents
,
}:
Args
):
Promise
<
string
[]
>
=>
{
const
bioEntityReactionsIds
=
(
bioEntityContents
||
[])
.
filter
(
c
=>
c
?.
bioEntity
?.
idReaction
)
.
map
(
c
=>
c
?.
bioEntity
?.
id
)
.
filter
((
id
):
id
is
number
=>
typeof
id
===
'
number
'
);
if
(
bioEntityReactionsIds
.
length
===
ZERO
)
{
return
[];
}
const
result
=
await
dispatch
(
getReactionsByIds
({
ids
:
bioEntityReactionsIds
,
shouldConcat
:
true
,
}),
);
if
(
typeof
result
.
payload
===
'
string
'
)
{
return
[];
}
const
reactions
=
result
.
payload
?.
data
;
if
(
!
reactions
||
reactions
.
length
===
SIZE_OF_EMPTY_ARRAY
)
{
return
[];
}
const
bioEntitiesIds
=
reactions
.
map
(
reaction
=>
getBioEntitiesIdsFromReaction
(
reaction
)).
flat
();
// dispatch(openReactionDrawerById(reactions[FIRST_ARRAY_ELEMENT].id));
dispatch
(
selectTab
(
''
));
return
bioEntitiesIds
;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment