Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wallet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
hive
wallet
Commits
9d3ebe72
Commit
9d3ebe72
authored
2 years ago
by
Quoc Huy Nguyen Dinh
Browse files
Options
Downloads
Patches
Plain Diff
Fix witness rank display & simplify witness owner display logic
parent
bc5478f4
No related branches found
No related tags found
2 merge requests
!142
merge develop to master for new release
,
!140
Fix witness rank display & simplify witness owner display logic
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/components/pages/Witnesses.jsx
+41
-98
41 additions, 98 deletions
src/app/components/pages/Witnesses.jsx
with
41 additions
and
98 deletions
src/app/components/pages/Witnesses.jsx
+
41
−
98
View file @
9d3ebe72
...
@@ -246,13 +246,12 @@ class Witnesses extends React.Component {
...
@@ -246,13 +246,12 @@ class Witnesses extends React.Component {
);
);
});
});
let
witness_vote_count
=
30
;
let
witness_vote_count
=
30
;
let
rank
=
0
;
let
foundWitnessToHighlight
=
false
;
let
foundWitnessToHighlight
=
false
;
let
previousTotalVoteHpf
=
0
;
let
previousTotalVoteHpf
=
0
;
const
now
=
Moment
();
const
now
=
Moment
();
const
processedWitnesses
=
sortedWitnesses
.
map
((
it
em
)
=>
{
const
processedWitnesses
=
sortedWitnesses
.
map
((
w
it
nessEntry
,
witnessIndex
)
=>
{
const
witnessName
=
it
em
.
get
(
'
owner
'
);
const
witnessName
=
w
it
nessEntry
.
get
(
'
owner
'
);
if
(
witnessName
===
witnessToHighlight
)
{
if
(
witnessName
===
witnessToHighlight
)
{
foundWitnessToHighlight
=
true
;
foundWitnessToHighlight
=
true
;
}
}
...
@@ -275,11 +274,11 @@ class Witnesses extends React.Component {
...
@@ -275,11 +274,11 @@ class Witnesses extends React.Component {
.
split
(
'
,
'
);
.
split
(
'
,
'
);
}
}
witnessOwnerNames
=
witnessOwnerNames
.
filter
((
ownerName
)
=>
{
witnessOwnerNames
=
witnessOwnerNames
.
filter
((
ownerName
)
=>
{
return
ownerName
!==
it
em
.
get
(
'
owner
'
);
return
ownerName
!==
w
it
nessEntry
.
get
(
'
owner
'
);
});
});
}
}
const
totalVotesVests
=
it
em
.
get
(
'
votes
'
);
const
totalVotesVests
=
w
it
nessEntry
.
get
(
'
votes
'
);
const
totalVotesHpf
=
vestsToHpf
(
const
totalVotesHpf
=
vestsToHpf
(
state
,
state
,
`
${
totalVotesVests
/
1000000
}
VESTS`
`
${
totalVotesVests
/
1000000
}
VESTS`
...
@@ -300,12 +299,12 @@ class Witnesses extends React.Component {
...
@@ -300,12 +299,12 @@ class Witnesses extends React.Component {
previousTotalVoteHpf
=
totalVotesHpf
;
previousTotalVoteHpf
=
totalVotesHpf
;
const
thread
=
it
em
.
get
(
'
url
'
).
replace
(
'
steemit.com
'
,
'
hive.blog
'
);
const
thread
=
w
it
nessEntry
.
get
(
'
url
'
).
replace
(
'
steemit.com
'
,
'
hive.blog
'
);
const
myVote
=
witness_votes
const
myVote
=
witness_votes
?
witness_votes
.
has
(
witnessName
)
?
witness_votes
.
has
(
witnessName
)
:
null
;
:
null
;
const
signingKey
=
it
em
.
get
(
'
signing_key
'
);
const
signingKey
=
w
it
nessEntry
.
get
(
'
signing_key
'
);
let
witnessCreated
=
it
em
.
get
(
'
created
'
);
let
witnessCreated
=
w
it
nessEntry
.
get
(
'
created
'
);
if
(
witnessCreated
===
'
1970-01-01T00:00:00
'
)
{
if
(
witnessCreated
===
'
1970-01-01T00:00:00
'
)
{
witnessCreated
=
'
2016-06-01T00:00:00
'
;
witnessCreated
=
'
2016-06-01T00:00:00
'
;
}
}
...
@@ -327,10 +326,10 @@ class Witnesses extends React.Component {
...
@@ -327,10 +326,10 @@ class Witnesses extends React.Component {
witnessAge
=
`
${
witnessAgeWeeks
}
${
tt
(
'
g.weeks
'
)}
`
;
witnessAge
=
`
${
witnessAgeWeeks
}
${
tt
(
'
g.weeks
'
)}
`
;
}
}
const
lastBlock
=
it
em
.
get
(
'
last_confirmed_block_num
'
);
const
lastBlock
=
w
it
nessEntry
.
get
(
'
last_confirmed_block_num
'
);
const
runningVersion
=
it
em
.
get
(
'
running_version
'
);
const
runningVersion
=
w
it
nessEntry
.
get
(
'
running_version
'
);
const
hbdExchangeRate
=
it
em
.
get
(
'
hbd_exchange_rate
'
);
const
hbdExchangeRate
=
w
it
nessEntry
.
get
(
'
hbd_exchange_rate
'
);
const
hbdExchangeUpdateDate
=
it
em
.
get
(
'
last_hbd_exchange_update
'
);
const
hbdExchangeUpdateDate
=
w
it
nessEntry
.
get
(
'
last_hbd_exchange_update
'
);
const
noBlock7days
=
(
head_block
-
lastBlock
)
*
3
>
604800
;
const
noBlock7days
=
(
head_block
-
lastBlock
)
*
3
>
604800
;
const
isDisabled
=
signingKey
==
DISABLED_SIGNING_KEY
;
const
isDisabled
=
signingKey
==
DISABLED_SIGNING_KEY
;
const
votingActive
=
witnessVotesInProgress
.
has
(
witnessName
);
const
votingActive
=
witnessVotesInProgress
.
has
(
witnessName
);
...
@@ -395,17 +394,22 @@ class Witnesses extends React.Component {
...
@@ -395,17 +394,22 @@ class Witnesses extends React.Component {
// Don't display the witness
// Don't display the witness
if
(
if
(
// If
rank
over 100
// If
index
over 100
rank
>
100
witnessIndex
>
100
// And no blocked produced for over 30 days
// And no blocked produced for over 30 days
&&
witnessLastBlockAgeInDays
>
witnessFilterLastBlockAgeThresholdInDays
&&
witnessLastBlockAgeInDays
>
witnessFilterLastBlockAgeThresholdInDays
// And not voted by current user
// And not voted by current user
&&
!
myVote
&&
!
myVote
)
{
)
{
rank
+=
1
;
return
null
;
return
null
;
}
}
const
rank
=
witnessIndex
+
1
;
const
array2list
=
(
array
)
=>
{
const
lastElement
=
array
.
pop
();
return
array
.
length
?
`
${
array
.
join
(
'
,
'
)}
&
${
lastElement
}
`
:
lastElement
;
};
return
(
return
(
<
tr
<
tr
key
=
{
witnessName
}
key
=
{
witnessName
}
...
@@ -415,13 +419,10 @@ class Witnesses extends React.Component {
...
@@ -415,13 +419,10 @@ class Witnesses extends React.Component {
})
}
})
}
>
>
<
td
className
=
"Witnesses__rank"
>
<
td
className
=
"Witnesses__rank"
>
{
rank
<
10
&&
'
0
'
}
{
rank
<
10
?
`0
${
rank
}
`
:
rank
}
{
rank
+=
1
}
<
span
className
=
{
classUp
}
>
<
span
className
=
{
classUp
}
>
{
votingActive
?
(
{
votingActive
?
up
:
(
up
)
:
(
<
a
<
a
href
=
"#"
href
=
"#"
onClick
=
{
accountWitnessVote
.
bind
(
onClick
=
{
accountWitnessVote
.
bind
(
...
@@ -444,9 +445,7 @@ class Witnesses extends React.Component {
...
@@ -444,9 +445,7 @@ class Witnesses extends React.Component {
<
Link
<
Link
to
=
{
`
${
$STM_Config
.
social_url
}
/@
${
witnessName
}
`
}
to
=
{
`
${
$STM_Config
.
social_url
}
/@
${
witnessName
}
`
}
style
=
{
ownerStyle
}
style
=
{
ownerStyle
}
title
=
{
tt
(
title
=
{
tt
(
'
witnesses_jsx.navigate_to_witness_profile
'
)
}
'
witnesses_jsx.navigate_to_witness_profile
'
)
}
>
>
<
Userpic
<
Userpic
account
=
{
witnessName
}
account
=
{
witnessName
}
...
@@ -460,38 +459,12 @@ class Witnesses extends React.Component {
...
@@ -460,38 +459,12 @@ class Witnesses extends React.Component {
<
div
>
<
div
>
{
witnessSocialLink
(
witnessName
)
}
{
witnessSocialLink
(
witnessName
)
}
{
witnessOwnerNames
&&
witnessOwnerNames
.
length
>
0
&&
(
{
witnessOwnerNames
&&
witnessOwnerNames
.
length
>
0
&&
(
<
span
>
<
span
>
{
'
'
}
{
'
'
}
{
tt
(
'
witnesses_jsx.by
'
)
}
{
tt
(
'
witnesses_jsx.by
'
)
}
{
'
'
}
{
'
'
}
{
witnessOwnerNames
.
map
(
{
array2list
(
witnessOwnerNames
)
}
(
ownerName
,
index
)
=>
{
</
span
>
if
(
witnessOwnerNames
.
length
>
1
&&
index
===
witnessOwnerNames
.
length
-
1
)
{
return
(
<
span
key
=
{
ownerName
}
>
{
'
'
}
&
{
'
'
}
{
witnessSocialLink
(
ownerName
)
}
</
span
>
);
}
return
(
<
span
key
=
{
ownerName
}
>
{
index
>
0
&&
'
,
'
}
{
witnessSocialLink
(
ownerName
)
}
</
span
>
);
}
)
}
</
span
>
)
}
)
}
<
Link
<
Link
to
=
{
`/~witnesses?highlight=
${
witnessName
}
`
}
to
=
{
`/~witnesses?highlight=
${
witnessName
}
`
}
...
@@ -501,9 +474,7 @@ class Witnesses extends React.Component {
...
@@ -501,9 +474,7 @@ class Witnesses extends React.Component {
witnessName
,
witnessName
,
]);
]);
}
}
}
}
title
=
{
tt
(
title
=
{
tt
(
'
witnesses_jsx.link_to_highlight_witness
'
)
}
'
witnesses_jsx.link_to_highlight_witness
'
)
}
>
>
<
Icon
<
Icon
name
=
"chain"
name
=
"chain"
...
@@ -519,15 +490,11 @@ class Witnesses extends React.Component {
...
@@ -519,15 +490,11 @@ class Witnesses extends React.Component {
<
strong
>
<
strong
>
<
span
<
span
role
=
"img"
role
=
"img"
aria-label
=
{
tt
(
aria-label
=
{
tt
(
'
witnesses_jsx.not_produced_over_a_week
'
)
}
'
witnesses_jsx.not_produced_over_a_week
'
)
}
>
>
⚠️
⚠️
</
span
>
</
span
>
{
tt
(
{
tt
(
'
witnesses_jsx.not_produced_over_a_week
'
)
}
'
witnesses_jsx.not_produced_over_a_week
'
)
}
</
strong
>
</
strong
>
</
div
>
</
div
>
)
}
)
}
...
@@ -543,14 +510,11 @@ class Witnesses extends React.Component {
...
@@ -543,14 +510,11 @@ class Witnesses extends React.Component {
to
=
{
`https://hiveblocks.com/b/
${
lastBlock
}
`
}
to
=
{
`https://hiveblocks.com/b/
${
lastBlock
}
`
}
target
=
"_blank"
target
=
"_blank"
>
>
#
{
`#
${
lastBlock
}
`
}
{
lastBlock
}
</
Link
>
</
Link
>
{
'
'
}
{
'
'
}
{
blockGap
(
head_block
,
lastBlock
)
}
{
blockGap
(
head_block
,
lastBlock
)
}
{
'
'
}
{
` on v
${
runningVersion
}
`
}
on v
{
runningVersion
}
</
div
>
</
div
>
{
isDisabled
&&
(
{
isDisabled
&&
(
<
div
>
<
div
>
...
@@ -564,9 +528,7 @@ class Witnesses extends React.Component {
...
@@ -564,9 +528,7 @@ class Witnesses extends React.Component {
)
}
)
}
{
!
isDisabled
&&
(
{
!
isDisabled
&&
(
<
div
>
<
div
>
{
`
${
tt
(
{
`
${
tt
(
'
witnesses_jsx.witness_age
'
)}
:
${
witnessAge
}
`
}
'
witnesses_jsx.witness_age
'
)}
:
${
witnessAge
}
`
}
</
div
>
</
div
>
)
}
)
}
</
small
>
</
small
>
...
@@ -627,11 +589,7 @@ class Witnesses extends React.Component {
...
@@ -627,11 +589,7 @@ class Witnesses extends React.Component {
)
:
(
)
:
(
<
a
<
a
href
=
"#"
href
=
"#"
onClick
=
{
accountWitnessVote
.
bind
(
onClick
=
{
accountWitnessVote
.
bind
(
this
,
item
,
false
)
}
this
,
item
,
false
)
}
title
=
{
tt
(
'
g.remove_vote
'
)
}
title
=
{
tt
(
'
g.remove_vote
'
)
}
>
>
{
up
}
{
up
}
...
@@ -657,16 +615,11 @@ class Witnesses extends React.Component {
...
@@ -657,16 +615,11 @@ class Witnesses extends React.Component {
<
div
>
<
div
>
<
p
>
<
p
>
<
strong
>
<
strong
>
{
tt
(
{
tt
(
'
witnesses_jsx.you_have_votes_remaining
'
,
{
count
:
witness_vote_count
})
}
'
witnesses_jsx.you_have_votes_remaining
'
,
{
count
:
witness_vote_count
}
)
}
.
.
</
strong
>
</
strong
>
{
'
'
}
{
'
'
}
{
tt
(
{
tt
(
'
witnesses_jsx.you_can_vote_for_maximum_of_witnesses
'
)
}
'
witnesses_jsx.you_can_vote_for_maximum_of_witnesses
'
)
}
.
.
</
p
>
</
p
>
<
p
>
{
tt
(
'
witnesses_jsx.witness_list_notes
'
)
}
</
p
>
<
p
>
{
tt
(
'
witnesses_jsx.witness_list_notes
'
)
}
</
p
>
...
@@ -704,9 +657,7 @@ class Witnesses extends React.Component {
...
@@ -704,9 +657,7 @@ class Witnesses extends React.Component {
>
>
<
div
className
=
"column"
>
<
div
className
=
"column"
>
<
p
>
<
p
>
{
tt
(
{
tt
(
'
witnesses_jsx.if_you_want_to_vote_outside_of_top_enter_account_name
'
)
}
'
witnesses_jsx.if_you_want_to_vote_outside_of_top_enter_account_name
'
)
}
.
.
</
p
>
</
p
>
<
form
>
<
form
>
...
@@ -734,11 +685,7 @@ class Witnesses extends React.Component {
...
@@ -734,11 +685,7 @@ class Witnesses extends React.Component {
onClick
=
{
accountWitnessVote
.
bind
(
onClick
=
{
accountWitnessVote
.
bind
(
this
,
this
,
customUsername
,
customUsername
,
!
(
witness_votes
!
(
witness_votes
?
witness_votes
.
has
(
customUsername
)
:
null
)
?
witness_votes
.
has
(
customUsername
)
:
null
)
)
}
)
}
>
>
{
tt
(
'
g.vote
'
)
}
{
tt
(
'
g.vote
'
)
}
...
@@ -790,9 +737,7 @@ class Witnesses extends React.Component {
...
@@ -790,9 +737,7 @@ class Witnesses extends React.Component {
className
=
"button"
className
=
"button"
onClick
=
{
accountWitnessProxy
}
onClick
=
{
accountWitnessProxy
}
>
>
{
tt
(
{
tt
(
'
witnesses_jsx.witness_proxy_clear
'
)
}
'
witnesses_jsx.witness_proxy_clear
'
)
}
</
button
>
</
button
>
</
div
>
</
div
>
</
div
>
</
div
>
...
@@ -824,9 +769,7 @@ class Witnesses extends React.Component {
...
@@ -824,9 +769,7 @@ class Witnesses extends React.Component {
className
=
"button"
className
=
"button"
onClick
=
{
accountWitnessProxy
}
onClick
=
{
accountWitnessProxy
}
>
>
{
tt
(
{
tt
(
'
witnesses_jsx.witness_proxy_set
'
)
}
'
witnesses_jsx.witness_proxy_set
'
)
}
</
button
>
</
button
>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
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