Skip to content
GitLab
Explore
Sign in
Register
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
8c8448b4
Commit
8c8448b4
authored
4 years ago
by
Jason Salyers
Browse files
Options
Downloads
Patches
Plain Diff
[JES] Temporary fix to the vote button not changing state after votes
parent
28d65250
No related branches found
No related tags found
2 merge requests
!131
Develop
,
!129
[JES] Temporary fix to the vote button not changing state after votes
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/components/elements/Voting.jsx
+15
-3
15 additions, 3 deletions
src/app/components/elements/Voting.jsx
src/app/redux/GlobalReducer.js
+9
-2
9 additions, 2 deletions
src/app/redux/GlobalReducer.js
src/app/utils/steemApi.js
+3
-1
3 additions, 1 deletion
src/app/utils/steemApi.js
with
27 additions
and
6 deletions
src/app/components/elements/Voting.jsx
+
15
−
3
View file @
8c8448b4
...
@@ -21,6 +21,7 @@ import {
...
@@ -21,6 +21,7 @@ import {
import
DropdownMenu
from
'
app/components/elements/DropdownMenu
'
;
import
DropdownMenu
from
'
app/components/elements/DropdownMenu
'
;
import
TimeAgoWrapper
from
'
app/components/elements/TimeAgoWrapper
'
;
import
TimeAgoWrapper
from
'
app/components/elements/TimeAgoWrapper
'
;
import
Dropdown
from
'
app/components/elements/Dropdown
'
;
import
Dropdown
from
'
app/components/elements/Dropdown
'
;
import
{
List
}
from
'
immutable
'
;
const
ABOUT_FLAG
=
(
const
ABOUT_FLAG
=
(
<
div
>
<
div
>
...
@@ -613,7 +614,7 @@ export default connect(
...
@@ -613,7 +614,7 @@ export default connect(
// mapStateToProps
// mapStateToProps
(
state
,
ownProps
)
=>
{
(
state
,
ownProps
)
=>
{
const
post
=
const
post
=
ownProps
.
post
||
state
.
global
.
getIn
([
'
content
'
,
ownProps
.
post_ref
]);
state
.
global
.
getIn
([
'
content
'
,
ownProps
.
post_ref
])
||
ownProps
.
post
;
if
(
!
post
)
{
if
(
!
post
)
{
console
.
error
(
'
post_not_found
'
,
ownProps
);
console
.
error
(
'
post_not_found
'
,
ownProps
);
...
@@ -622,7 +623,8 @@ export default connect(
...
@@ -622,7 +623,8 @@ export default connect(
const
author
=
post
.
get
(
'
author
'
);
const
author
=
post
.
get
(
'
author
'
);
const
permlink
=
post
.
get
(
'
permlink
'
);
const
permlink
=
post
.
get
(
'
permlink
'
);
const
active_votes
=
post
.
get
(
'
active_votes
'
);
let
votes_key
=
[
'
content
'
,
author
+
'
/
'
+
permlink
,
'
active_votes
'
];
const
active_votes
=
state
.
global
.
getIn
(
votes_key
,
List
());
const
is_comment
=
post
.
get
(
'
depth
'
)
==
0
;
const
is_comment
=
post
.
get
(
'
depth
'
)
==
0
;
const
current
=
state
.
user
.
get
(
'
current
'
);
const
current
=
state
.
user
.
get
(
'
current
'
);
...
@@ -640,7 +642,17 @@ export default connect(
...
@@ -640,7 +642,17 @@ export default connect(
let
myVote
=
ownProps
.
myVote
||
null
;
// ownProps: test only
let
myVote
=
ownProps
.
myVote
||
null
;
// ownProps: test only
if
(
username
&&
active_votes
)
{
if
(
username
&&
active_votes
)
{
const
vote
=
active_votes
.
find
(
el
=>
el
.
get
(
'
voter
'
)
===
username
);
const
vote
=
active_votes
.
find
(
el
=>
el
.
get
(
'
voter
'
)
===
username
);
if
(
vote
)
myVote
=
parseInt
(
vote
.
get
(
'
rshares
'
),
10
);
if
(
vote
)
{
let
has_rshares
=
vote
.
get
(
'
rshares
'
)
!==
undefined
;
let
has_percent
=
vote
.
get
(
'
percent
'
)
!==
undefined
;
if
(
has_rshares
&&
!
has_percent
)
{
myVote
=
parseInt
(
vote
.
get
(
'
rshares
'
),
10
);
}
else
if
(
!
has_rshares
&&
has_percent
)
{
myVote
=
vote
.
get
(
'
percent
'
);
}
else
if
(
has_rshares
&&
has_percent
)
{
myVote
=
null
;
}
}
}
}
return
{
return
{
...
...
This diff is collapsed.
Click to expand it.
src/app/redux/GlobalReducer.js
+
9
−
2
View file @
8c8448b4
...
@@ -181,6 +181,14 @@ export default function reducer(state = defaultState, action = {}) {
...
@@ -181,6 +181,14 @@ export default function reducer(state = defaultState, action = {}) {
c
.
mergeDeep
(
content
)
c
.
mergeDeep
(
content
)
);
);
// merge vote info taking pending votes into account
let
votes_key
=
[
'
content
'
,
key
,
'
active_votes
'
];
let
old_votes
=
state
.
getIn
(
votes_key
,
List
());
let
new_votes
=
content
.
get
(
'
active_votes
'
);
const
{
merge
}
=
require
(
'
immutable
'
);
let
merged_votes
=
new_votes
.
merge
(
new_votes
,
old_votes
);
new_state
=
new_state
.
setIn
(
votes_key
,
merged_votes
);
// set creation-pending key (optimistic UI update)
// set creation-pending key (optimistic UI update)
if
(
content
.
get
(
'
depth
'
)
==
0
)
{
if
(
content
.
get
(
'
depth
'
)
==
0
)
{
const
category
=
content
.
get
(
'
category
'
);
const
category
=
content
.
get
(
'
category
'
);
...
@@ -246,10 +254,9 @@ export default function reducer(state = defaultState, action = {}) {
...
@@ -246,10 +254,9 @@ export default function reducer(state = defaultState, action = {}) {
const
idx
=
votes
.
findIndex
(
v
=>
v
.
get
(
'
voter
'
)
===
voter
);
const
idx
=
votes
.
findIndex
(
v
=>
v
.
get
(
'
voter
'
)
===
voter
);
votes
=
idx
===
-
1
?
votes
.
push
(
vote
)
:
votes
.
set
(
idx
,
vote
);
votes
=
idx
===
-
1
?
votes
.
push
(
vote
)
:
votes
.
set
(
idx
,
vote
);
console
.
log
(
'
Applying vote @ idx
'
,
idx
,
payload
);
// TODO: new state never returned -- masked by RECEIVE_CONTENT
// TODO: new state never returned -- masked by RECEIVE_CONTENT
state
.
setIn
(
key
,
votes
);
state
=
state
.
setIn
(
key
,
votes
);
return
state
;
return
state
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/app/utils/steemApi.js
+
3
−
1
View file @
8c8448b4
...
@@ -21,8 +21,10 @@ export async function callBridge(method, params) {
...
@@ -21,8 +21,10 @@ export async function callBridge(method, params) {
params
&&
params
&&
(
params
.
observer
===
null
||
params
.
observer
===
undefined
)
&&
(
params
.
observer
===
null
||
params
.
observer
===
undefined
)
&&
params
.
tag
===
'
my
'
params
.
tag
===
'
my
'
)
)
{
delete
params
.
tag
;
delete
params
.
tag
;
delete
params
.
observer
;
}
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
api
.
call
(
'
bridge.
'
+
method
,
params
,
function
(
err
,
data
)
{
api
.
call
(
'
bridge.
'
+
method
,
params
,
function
(
err
,
data
)
{
...
...
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