Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
5524c8d5
Commit
5524c8d5
authored
Mar 12, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace ref with state to fix test
parent
9a47831c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
useMarketplaceApps.tsx
ui/marketplace/useMarketplaceApps.tsx
+6
-5
Marketplace.pw.tsx
ui/pages/Marketplace.pw.tsx
+1
-1
No files found.
ui/marketplace/useMarketplaceApps.tsx
View file @
5524c8d5
...
@@ -57,15 +57,16 @@ export default function useMarketplaceApps(
...
@@ -57,15 +57,16 @@ export default function useMarketplaceApps(
const
apiFetch
=
useApiFetch
();
const
apiFetch
=
useApiFetch
();
// Update favorite apps only when selectedCategoryId changes to avoid sortApps to be called on each favorite app click
// Update favorite apps only when selectedCategoryId changes to avoid sortApps to be called on each favorite app click
const
lastFavoriteAppsRef
:
React
.
MutableRefObject
<
Array
<
string
>
|
undefined
>
=
React
.
useRef
();
const
[
snapshotFavoriteApps
,
setSnapshotFavoriteApps
]
=
React
.
useState
<
Array
<
string
>
|
undefined
>
();
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
if
(
isFavoriteAppsLoaded
)
{
if
(
isFavoriteAppsLoaded
)
{
lastFavoriteAppsRef
.
current
=
favoriteApps
;
setSnapshotFavoriteApps
(
favoriteApps
)
;
}
}
},
[
selectedCategoryId
,
isFavoriteAppsLoaded
]);
// eslint-disable-line react-hooks/exhaustive-deps
},
[
selectedCategoryId
,
isFavoriteAppsLoaded
]);
// eslint-disable-line react-hooks/exhaustive-deps
const
{
isPlaceholderData
,
isError
,
error
,
data
}
=
useQuery
<
unknown
,
ResourceError
<
unknown
>
,
Array
<
MarketplaceAppOverview
>>
({
const
{
isPlaceholderData
,
isError
,
error
,
data
}
=
useQuery
<
unknown
,
ResourceError
<
unknown
>
,
Array
<
MarketplaceAppOverview
>>
({
queryKey
:
[
'
marketplace-dapps
'
,
lastFavoriteAppsRef
.
current
,
favoriteApps
],
queryKey
:
[
'
marketplace-dapps
'
,
snapshotFavoriteApps
,
favoriteApps
],
queryFn
:
async
()
=>
{
queryFn
:
async
()
=>
{
if
(
!
feature
.
isEnabled
)
{
if
(
!
feature
.
isEnabled
)
{
return
[];
return
[];
...
@@ -75,10 +76,10 @@ export default function useMarketplaceApps(
...
@@ -75,10 +76,10 @@ export default function useMarketplaceApps(
return
apiFetch
(
'
marketplace_dapps
'
,
{
pathParams
:
{
chainId
:
config
.
chain
.
id
}
});
return
apiFetch
(
'
marketplace_dapps
'
,
{
pathParams
:
{
chainId
:
config
.
chain
.
id
}
});
}
}
},
},
select
:
(
data
)
=>
sortApps
(
data
as
Array
<
MarketplaceAppOverview
>
,
lastFavoriteAppsRef
.
current
||
[]),
select
:
(
data
)
=>
sortApps
(
data
as
Array
<
MarketplaceAppOverview
>
,
snapshotFavoriteApps
||
[]),
placeholderData
:
feature
.
isEnabled
?
Array
(
9
).
fill
(
MARKETPLACE_APP
)
:
undefined
,
placeholderData
:
feature
.
isEnabled
?
Array
(
9
).
fill
(
MARKETPLACE_APP
)
:
undefined
,
staleTime
:
Infinity
,
staleTime
:
Infinity
,
enabled
:
feature
.
isEnabled
&&
(
!
favoriteApps
||
Boolean
(
lastFavoriteAppsRef
.
current
)),
enabled
:
feature
.
isEnabled
&&
(
!
favoriteApps
||
Boolean
(
snapshotFavoriteApps
)),
});
});
const
displayedApps
=
React
.
useMemo
(()
=>
{
const
displayedApps
=
React
.
useMemo
(()
=>
{
...
...
ui/pages/Marketplace.pw.tsx
View file @
5524c8d5
...
@@ -18,7 +18,7 @@ const test = base.extend({
...
@@ -18,7 +18,7 @@ const test = base.extend({
])
as
any
,
])
as
any
,
});
});
test
(
'
base view +@dark-mode
'
,
async
({
mount
,
page
})
=>
{
test
(
'
base view +@
mobile +@
dark-mode
'
,
async
({
mount
,
page
})
=>
{
await
page
.
route
(
MARKETPLACE_CONFIG_URL
,
(
route
)
=>
route
.
fulfill
({
await
page
.
route
(
MARKETPLACE_CONFIG_URL
,
(
route
)
=>
route
.
fulfill
({
status
:
200
,
status
:
200
,
body
:
JSON
.
stringify
(
appsMock
),
body
:
JSON
.
stringify
(
appsMock
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment