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
8bf2f3e8
Commit
8bf2f3e8
authored
Apr 10, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use watchlist_address_id instead of fetching whole watchlist
parent
db540791
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
18 deletions
+15
-18
address.ts
types/api/address.ts
+1
-0
AddressDetails.tsx
ui/address/AddressDetails.tsx
+1
-0
AddressFavoriteButton.tsx
ui/address/details/AddressFavoriteButton.tsx
+10
-15
AddressHeadingInfo.tsx
ui/shared/AddressHeadingInfo.tsx
+3
-3
No files found.
types/api/address.ts
View file @
8bf2f3e8
...
@@ -32,6 +32,7 @@ export interface Address {
...
@@ -32,6 +32,7 @@ export interface Address {
private_tags
:
Array
<
AddressTag
>
|
null
;
private_tags
:
Array
<
AddressTag
>
|
null
;
public_tags
:
Array
<
AddressTag
>
|
null
;
public_tags
:
Array
<
AddressTag
>
|
null
;
token
:
TokenInfo
|
null
;
token
:
TokenInfo
|
null
;
watchlist_address_id
:
number
|
null
;
watchlist_names
:
Array
<
WatchlistName
>
|
null
;
watchlist_names
:
Array
<
WatchlistName
>
|
null
;
}
}
...
...
ui/address/AddressDetails.tsx
View file @
8bf2f3e8
...
@@ -56,6 +56,7 @@ const AddressDetails = ({ addressQuery, scrollRef }: Props) => {
...
@@ -56,6 +56,7 @@ const AddressDetails = ({ addressQuery, scrollRef }: Props) => {
implementation_name
:
null
,
implementation_name
:
null
,
implementation_address
:
null
,
implementation_address
:
null
,
token
:
null
,
token
:
null
,
watchlist_address_id
:
null
,
watchlist_names
:
null
,
watchlist_names
:
null
,
creation_tx_hash
:
null
,
creation_tx_hash
:
null
,
block_number_balance_updated_at
:
null
,
block_number_balance_updated_at
:
null
,
...
...
ui/address/details/AddressFavoriteButton.tsx
View file @
8bf2f3e8
...
@@ -8,7 +8,7 @@ import type { UserInfo } from 'types/api/account';
...
@@ -8,7 +8,7 @@ import type { UserInfo } from 'types/api/account';
import
starFilledIcon
from
'
icons/star_filled.svg
'
;
import
starFilledIcon
from
'
icons/star_filled.svg
'
;
import
starOutlineIcon
from
'
icons/star_outline.svg
'
;
import
starOutlineIcon
from
'
icons/star_outline.svg
'
;
import
{
resourceKey
}
from
'
lib/api/resources
'
;
import
{
resourceKey
}
from
'
lib/api/resources
'
;
import
useApiQuery
,
{
getResourceKey
}
from
'
lib/api/useApiQuery
'
;
import
{
getResourceKey
}
from
'
lib/api/useApiQuery
'
;
import
useLoginUrl
from
'
lib/hooks/useLoginUrl
'
;
import
useLoginUrl
from
'
lib/hooks/useLoginUrl
'
;
import
usePreventFocusAfterModalClosing
from
'
lib/hooks/usePreventFocusAfterModalClosing
'
;
import
usePreventFocusAfterModalClosing
from
'
lib/hooks/usePreventFocusAfterModalClosing
'
;
import
WatchlistAddModal
from
'
ui/watchlist/AddressModal/AddressModal
'
;
import
WatchlistAddModal
from
'
ui/watchlist/AddressModal/AddressModal
'
;
...
@@ -17,10 +17,10 @@ import DeleteAddressModal from 'ui/watchlist/DeleteAddressModal';
...
@@ -17,10 +17,10 @@ import DeleteAddressModal from 'ui/watchlist/DeleteAddressModal';
interface
Props
{
interface
Props
{
className
?:
string
;
className
?:
string
;
hash
:
string
;
hash
:
string
;
isAdded
:
boolean
;
watchListId
:
number
|
null
;
}
}
const
AddressFavoriteButton
=
({
className
,
hash
,
isAdde
d
}:
Props
)
=>
{
const
AddressFavoriteButton
=
({
className
,
hash
,
watchListI
d
}:
Props
)
=>
{
const
addModalProps
=
useDisclosure
();
const
addModalProps
=
useDisclosure
();
const
deleteModalProps
=
useDisclosure
();
const
deleteModalProps
=
useDisclosure
();
const
queryClient
=
useQueryClient
();
const
queryClient
=
useQueryClient
();
...
@@ -30,15 +30,13 @@ const AddressFavoriteButton = ({ className, hash, isAdded }: Props) => {
...
@@ -30,15 +30,13 @@ const AddressFavoriteButton = ({ className, hash, isAdded }: Props) => {
const
isAuth
=
Boolean
(
profileData
);
const
isAuth
=
Boolean
(
profileData
);
const
loginUrl
=
useLoginUrl
();
const
loginUrl
=
useLoginUrl
();
const
watchListQuery
=
useApiQuery
(
'
watchlist
'
,
{
queryOptions
:
{
enabled
:
isAdded
}
});
const
handleClick
=
React
.
useCallback
(()
=>
{
const
handleClick
=
React
.
useCallback
(()
=>
{
if
(
!
isAuth
)
{
if
(
!
isAuth
)
{
window
.
location
.
assign
(
loginUrl
);
window
.
location
.
assign
(
loginUrl
);
return
;
return
;
}
}
isAdde
d
?
deleteModalProps
.
onOpen
()
:
addModalProps
.
onOpen
();
watchListI
d
?
deleteModalProps
.
onOpen
()
:
addModalProps
.
onOpen
();
},
[
addModalProps
,
deleteModalProps
,
isAdde
d
,
isAuth
,
loginUrl
]);
},
[
addModalProps
,
deleteModalProps
,
watchListI
d
,
isAuth
,
loginUrl
]);
const
handleAddOrDeleteSuccess
=
React
.
useCallback
(
async
()
=>
{
const
handleAddOrDeleteSuccess
=
React
.
useCallback
(
async
()
=>
{
const
queryKey
=
getResourceKey
(
'
address
'
,
{
pathParams
:
{
hash
:
router
.
query
.
hash
?.
toString
()
}
});
const
queryKey
=
getResourceKey
(
'
address
'
,
{
pathParams
:
{
hash
:
router
.
query
.
hash
?.
toString
()
}
});
...
@@ -57,18 +55,15 @@ const AddressFavoriteButton = ({ className, hash, isAdded }: Props) => {
...
@@ -57,18 +55,15 @@ const AddressFavoriteButton = ({ className, hash, isAdded }: Props) => {
const
formData
=
React
.
useMemo
(()
=>
{
const
formData
=
React
.
useMemo
(()
=>
{
return
{
return
{
address_hash
:
hash
,
address_hash
:
hash
,
// FIXME temporary solution
id
:
String
(
watchListId
),
// there is no endpoint in api what can return watchlist address info by its hash
// so we look up in the whole watchlist and hope we can find a necessary item
id
:
watchListQuery
.
data
?.
find
((
address
)
=>
address
.
address
?.
hash
===
hash
)?.
id
||
''
,
};
};
},
[
hash
,
watchList
Query
.
data
]);
},
[
hash
,
watchList
Id
]);
return
(
return
(
<>
<>
<
Tooltip
label=
{
`${
isAdde
d ? 'Remove address from Watch list' : 'Add address to Watch list' }`
}
>
<
Tooltip
label=
{
`${
watchListI
d ? 'Remove address from Watch list' : 'Add address to Watch list' }`
}
>
<
IconButton
<
IconButton
isActive=
{
isAdded
}
isActive=
{
Boolean
(
watchListId
)
}
className=
{
className
}
className=
{
className
}
aria
-
label=
"edit"
aria
-
label=
"edit"
variant=
"outline"
variant=
"outline"
...
@@ -76,7 +71,7 @@ const AddressFavoriteButton = ({ className, hash, isAdded }: Props) => {
...
@@ -76,7 +71,7 @@ const AddressFavoriteButton = ({ className, hash, isAdded }: Props) => {
pl=
"6px"
pl=
"6px"
pr=
"6px"
pr=
"6px"
onClick=
{
handleClick
}
onClick=
{
handleClick
}
icon=
{
<
Icon
as=
{
isAdde
d
?
starFilledIcon
:
starOutlineIcon
}
boxSize=
{
5
}
/>
}
icon=
{
<
Icon
as=
{
watchListI
d
?
starFilledIcon
:
starOutlineIcon
}
boxSize=
{
5
}
/>
}
onFocusCapture=
{
usePreventFocusAfterModalClosing
()
}
onFocusCapture=
{
usePreventFocusAfterModalClosing
()
}
/>
/>
</
Tooltip
>
</
Tooltip
>
...
...
ui/shared/AddressHeadingInfo.tsx
View file @
8bf2f3e8
import
{
Flex
}
from
'
@chakra-ui/react
'
;
import
{
Flex
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
Address
Param
}
from
'
types/api/addressParam
s
'
;
import
type
{
Address
}
from
'
types/api/addres
s
'
;
import
type
{
TokenInfo
}
from
'
types/api/token
'
;
import
type
{
TokenInfo
}
from
'
types/api/token
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
...
@@ -13,7 +13,7 @@ import AddressLink from 'ui/shared/address/AddressLink';
...
@@ -13,7 +13,7 @@ import AddressLink from 'ui/shared/address/AddressLink';
import
CopyToClipboard
from
'
ui/shared/CopyToClipboard
'
;
import
CopyToClipboard
from
'
ui/shared/CopyToClipboard
'
;
interface
Props
{
interface
Props
{
address
:
Pick
<
Address
Param
,
'
hash
'
|
'
is_contract
'
|
'
implementation_name
'
|
'
watchlist_names
'
>
;
address
:
Pick
<
Address
,
'
hash
'
|
'
is_contract
'
|
'
implementation_name
'
|
'
watchlist_names
'
|
'
watchlist_address_id
'
>
;
token
?:
TokenInfo
|
null
;
token
?:
TokenInfo
|
null
;
isLinkDisabled
?:
boolean
;
isLinkDisabled
?:
boolean
;
}
}
...
@@ -36,7 +36,7 @@ const AddressHeadingInfo = ({ address, token, isLinkDisabled }: Props) => {
...
@@ -36,7 +36,7 @@ const AddressHeadingInfo = ({ address, token, isLinkDisabled }: Props) => {
<
CopyToClipboard
text=
{
address
.
hash
}
/>
<
CopyToClipboard
text=
{
address
.
hash
}
/>
{
address
.
is_contract
&&
token
&&
<
AddressAddToMetaMask
ml=
{
2
}
token=
{
token
}
/>
}
{
address
.
is_contract
&&
token
&&
<
AddressAddToMetaMask
ml=
{
2
}
token=
{
token
}
/>
}
{
!
address
.
is_contract
&&
(
{
!
address
.
is_contract
&&
(
<
AddressFavoriteButton
hash=
{
address
.
hash
}
isAdded=
{
Boolean
(
address
.
watchlist_names
?.
length
)
}
ml=
{
3
}
/>
<
AddressFavoriteButton
hash=
{
address
.
hash
}
watchListId=
{
address
.
watchlist_address_id
}
ml=
{
3
}
/>
)
}
)
}
<
AddressQrCode
hash=
{
address
.
hash
}
ml=
{
2
}
/>
<
AddressQrCode
hash=
{
address
.
hash
}
ml=
{
2
}
/>
</
Flex
>
</
Flex
>
...
...
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