Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
condenser
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
condenser
Commits
30ce20e0
Commit
30ce20e0
authored
8 years ago
by
Tim
Browse files
Options
Downloads
Patches
Plain Diff
save separate weight for posts vs comments. resolves
#91
parent
2b52b6e0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/components/elements/Voting.jsx
+7
-5
7 additions, 5 deletions
app/components/elements/Voting.jsx
with
7 additions
and
5 deletions
app/components/elements/Voting.jsx
+
7
−
5
View file @
30ce20e0
...
...
@@ -36,6 +36,7 @@ class Voting extends React.Component {
author
:
React
.
PropTypes
.
string
,
// post was deleted
permlink
:
React
.
PropTypes
.
string
,
username
:
React
.
PropTypes
.
string
,
is_comment
:
React
.
PropTypes
.
bool
,
myVote
:
React
.
PropTypes
.
number
,
active_votes
:
React
.
PropTypes
.
object
,
loggedin
:
React
.
PropTypes
.
bool
,
...
...
@@ -62,10 +63,10 @@ class Voting extends React.Component {
e
.
preventDefault
();
if
(
this
.
props
.
voting
)
return
this
.
setState
({
votingUp
:
true
,
votingDown
:
false
})
const
{
author
,
permlink
,
username
,
myVote
}
=
this
.
props
const
{
author
,
permlink
,
username
,
myVote
,
is_comment
}
=
this
.
props
// already voted Up, remove the vote
if
(
this
.
props
.
vesting_shares
>
VOTE_WEIGHT_DROPDOWN_THRESHOLD
)
{
localStorage
.
setItem
(
'
voteWeight-
'
+
username
,
this
.
state
.
weight
);
localStorage
.
setItem
(
'
voteWeight-
'
+
username
+
(
is_comment
?
'
-comment
'
:
''
)
,
this
.
state
.
weight
);
}
const
weight
=
myVote
>
0
?
0
:
this
.
state
.
weight
if
(
this
.
state
.
showWeight
)
this
.
setState
({
showWeight
:
false
})
...
...
@@ -85,11 +86,11 @@ class Voting extends React.Component {
};
this
.
toggleWeight
=
e
=>
{
e
.
preventDefault
();
const
{
username
}
=
this
.
props
const
{
username
,
is_comment
}
=
this
.
props
// Upon opening dialog, read last used weight (this works accross tabs)
if
(
!
this
.
state
.
showWeight
)
{
localStorage
.
removeItem
(
'
vote_weight
'
);
// deprecated. remove this line after 8/31
const
saved_weight
=
localStorage
.
getItem
(
'
voteWeight-
'
+
username
);
const
saved_weight
=
localStorage
.
getItem
(
'
voteWeight-
'
+
username
+
(
is_comment
?
'
-comment
'
:
''
)
);
this
.
setState
({
weight
:
saved_weight
?
parseInt
(
saved_weight
,
10
)
:
10000
});
}
this
.
setState
({
showWeight
:
!
this
.
state
.
showWeight
})
...
...
@@ -219,6 +220,7 @@ export default connect(
const
permlink
=
post
.
get
(
'
permlink
'
)
const
last_payout
=
post
.
get
(
'
last_payout
'
)
const
active_votes
=
post
.
get
(
'
active_votes
'
)
const
is_comment
=
post
.
get
(
'
parent_author
'
)
!==
''
const
current_account
=
state
.
user
.
get
(
'
current
'
)
const
username
=
current_account
?
current_account
.
get
(
'
username
'
)
:
null
;
const
vesting_shares
=
current_account
?
current_account
.
get
(
'
vesting_shares
'
)
:
0.0
;
...
...
@@ -231,7 +233,7 @@ export default connect(
}
return
{
...
ownProps
,
myVote
,
author
,
permlink
,
username
,
active_votes
,
vesting_shares
,
myVote
,
author
,
permlink
,
username
,
active_votes
,
vesting_shares
,
is_comment
,
loggedin
:
username
!=
null
,
voting
}
...
...
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