Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
hive
wallet
Commits
3dcb028f
Commit
3dcb028f
authored
Apr 15, 2019
by
Efe
Committed by
Jonathan Porta
Jul 26, 2019
Browse files
create separate reducer file
parent
95fdc0c7
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/app/components/pages/SteemProposalSystem.jsx
View file @
3dcb028f
...
...
@@ -391,14 +391,14 @@ module.exports = {
state
=>
{
const
user
=
state
.
user
.
get
(
'
current
'
);
const
currentUser
=
user
&&
user
.
get
(
'
username
'
);
const
proposals
=
state
.
glob
al
.
get
(
'
proposals
'
,
List
());
const
proposals
=
state
.
propos
al
.
get
(
'
proposals
'
,
List
());
const
last
=
proposals
.
size
-
1
;
const
last_id
=
(
proposals
.
size
&&
proposals
.
get
(
last
).
get
(
'
id
'
))
||
null
;
const
newProposals
=
proposals
.
size
>=
10
?
proposals
.
delete
(
last
)
:
proposals
;
const
voterProposals
=
state
.
glob
al
.
get
(
'
voterProposals
'
,
List
());
const
votesInProgress
=
state
.
glob
al
.
get
(
const
voterProposals
=
state
.
propos
al
.
get
(
'
voterProposals
'
,
List
());
const
votesInProgress
=
state
.
propos
al
.
get
(
`transaction_proposal_vote_active_
${
currentUser
}
`
,
List
()
);
...
...
src/app/redux/GlobalReducer.js
View file @
3dcb028f
...
...
@@ -32,10 +32,6 @@ const SHOW_DIALOG = 'global/SHOW_DIALOG';
const
HIDE_DIALOG
=
'
global/HIDE_DIALOG
'
;
const
ADD_ACTIVE_WITNESS_VOTE
=
'
global/ADD_ACTIVE_WITNESS_VOTE
'
;
const
REMOVE_ACTIVE_WITNESS_VOTE
=
'
global/REMOVE_ACTIVE_WITNESS_VOTE
'
;
const
ADD_ACTIVE_PROPOSAL_VOTE
=
'
global/ADD_ACTIVE_PROPOSAL_VOTE
'
;
const
REMOVE_ACTIVE_PROPOSAL_VOTE
=
'
global/REMOVE_ACTIVE_PROPOSAL_VOTE
'
;
const
RECEIVE_LIST_PROPOSALS
=
'
global/RECEIVE_LIST_PROPOSALS
'
;
const
RECEIVE_LIST_VOTER_PROPOSALS
=
'
global/RECEIVE_LIST_VOTER_PROPOSALS
'
;
// Saga-related:
export
const
GET_STATE
=
'
global/GET_STATE
'
;
...
...
@@ -326,32 +322,6 @@ export default function reducer(state = defaultState, action = {}) {
);
}
case
ADD_ACTIVE_PROPOSAL_VOTE
:
{
return
state
.
update
(
`transaction_proposal_vote_active_
${
payload
.
voter
}
`
,
List
(),
l
=>
l
.
push
(
payload
.
proposal_ids
[
0
])
);
}
case
REMOVE_ACTIVE_PROPOSAL_VOTE
:
{
return
state
.
update
(
`transaction_proposal_vote_active_
${
payload
.
voter
}
`
,
List
(),
l
=>
l
.
delete
(
l
.
indexOf
(
payload
.
proposal_ids
[
0
]))
);
}
case
RECEIVE_LIST_PROPOSALS
:
{
const
new_state
=
fromJS
(
payload
);
return
state
.
merge
(
new_state
);
}
case
RECEIVE_LIST_VOTER_PROPOSALS
:
{
const
new_state
=
fromJS
(
payload
);
return
state
.
merge
(
new_state
);
}
default
:
return
state
;
}
...
...
@@ -470,26 +440,6 @@ export const removeActiveWitnessVote = payload => ({
payload
,
});
export
const
addActiveProposalVote
=
payload
=>
({
type
:
ADD_ACTIVE_PROPOSAL_VOTE
,
payload
,
});
export
const
removeActiveProposalVote
=
payload
=>
({
type
:
REMOVE_ACTIVE_PROPOSAL_VOTE
,
payload
,
});
export
const
receiveListProposals
=
payload
=>
({
type
:
RECEIVE_LIST_PROPOSALS
,
payload
,
});
export
const
receiveListVoterProposals
=
payload
=>
({
type
:
RECEIVE_LIST_VOTER_PROPOSALS
,
payload
,
});
export
const
getState
=
payload
=>
({
type
:
GET_STATE
,
payload
,
...
...
src/app/redux/ProposalReducer.js
0 → 100644
View file @
3dcb028f
import
{
Map
,
Set
,
List
,
fromJS
}
from
'
immutable
'
;
const
ADD_ACTIVE_PROPOSAL_VOTE
=
'
global/ADD_ACTIVE_PROPOSAL_VOTE
'
;
const
REMOVE_ACTIVE_PROPOSAL_VOTE
=
'
global/REMOVE_ACTIVE_PROPOSAL_VOTE
'
;
const
RECEIVE_LIST_PROPOSALS
=
'
global/RECEIVE_LIST_PROPOSALS
'
;
const
RECEIVE_LIST_VOTER_PROPOSALS
=
'
global/RECEIVE_LIST_VOTER_PROPOSALS
'
;
export
const
defaultState
=
Map
();
export
default
function
reducer
(
state
=
defaultState
,
action
=
{})
{
const
payload
=
action
.
payload
;
switch
(
action
.
type
)
{
case
ADD_ACTIVE_PROPOSAL_VOTE
:
{
return
state
.
update
(
`transaction_proposal_vote_active_
${
payload
.
voter
}
`
,
List
(),
l
=>
l
.
push
(
payload
.
proposal_ids
[
0
])
);
}
case
REMOVE_ACTIVE_PROPOSAL_VOTE
:
{
return
state
.
update
(
`transaction_proposal_vote_active_
${
payload
.
voter
}
`
,
List
(),
l
=>
l
.
delete
(
l
.
indexOf
(
payload
.
proposal_ids
[
0
]))
);
}
case
RECEIVE_LIST_PROPOSALS
:
{
const
new_state
=
fromJS
(
payload
);
return
state
.
merge
(
new_state
);
}
case
RECEIVE_LIST_VOTER_PROPOSALS
:
{
const
new_state
=
fromJS
(
payload
);
return
state
.
merge
(
new_state
);
}
default
:
return
state
;
}
}
export
const
addActiveProposalVote
=
payload
=>
({
type
:
ADD_ACTIVE_PROPOSAL_VOTE
,
payload
,
});
export
const
removeActiveProposalVote
=
payload
=>
({
type
:
REMOVE_ACTIVE_PROPOSAL_VOTE
,
payload
,
});
export
const
receiveListProposals
=
payload
=>
({
type
:
RECEIVE_LIST_PROPOSALS
,
payload
,
});
export
const
receiveListVoterProposals
=
payload
=>
({
type
:
RECEIVE_LIST_VOTER_PROPOSALS
,
payload
,
});
src/app/redux/ProposalSaga.js
View file @
3dcb028f
import
{
api
}
from
'
@blocktradesdev/steem-js
'
;
import
{
call
,
put
,
takeEvery
}
from
'
redux-saga/effects
'
;
import
*
as
glob
alActions
from
'
./
Glob
alReducer
'
;
import
*
as
propos
alActions
from
'
./
Propos
alReducer
'
;
const
LIST_PROPOSALS
=
'
fetchDataSaga/LIST_PROPOSALS
'
;
const
LIST_VOTER_PROPOSALS
=
'
fetchDataSaga/LIST_VOTER_PROPOSALS
'
;
...
...
@@ -55,7 +55,7 @@ export function* listProposals({
}
}
yield
put
(
glob
alActions
.
receiveListProposals
({
proposals
}));
yield
put
(
propos
alActions
.
receiveListProposals
({
proposals
}));
if
(
resolve
&&
proposals
)
{
resolve
(
proposals
);
}
else
if
(
reject
&&
!
proposals
)
{
...
...
@@ -108,7 +108,7 @@ export function* listVoterProposals({
}
}
yield
put
(
glob
alActions
.
receiveListVoterProposals
({
voterProposals
}));
yield
put
(
propos
alActions
.
receiveListVoterProposals
({
voterProposals
}));
if
(
resolve
&&
voterProposals
[
start
].
length
>
0
)
{
resolve
(
voterProposals
);
}
else
if
(
reject
&&
!
voterProposals
)
{
...
...
src/app/redux/RootReducer.js
View file @
3dcb028f
...
...
@@ -9,6 +9,7 @@ import marketReducer from './MarketReducer';
import
userReducer
from
'
./UserReducer
'
;
import
transactionReducer
from
'
./TransactionReducer
'
;
import
offchainReducer
from
'
./OffchainReducer
'
;
import
proposalReducer
from
'
./ProposalReducer
'
;
function
initReducer
(
reducer
,
type
)
{
return
(
state
,
action
)
=>
{
...
...
@@ -54,4 +55,5 @@ export default combineReducers({
routing
:
initReducer
(
routerReducer
),
app
:
initReducer
(
appReducer
),
form
:
formReducer
,
proposal
:
initReducer
(
proposalReducer
,
'
proposal
'
),
});
src/app/redux/TransactionSaga.js
View file @
3dcb028f
...
...
@@ -13,6 +13,7 @@ import * as appActions from 'app/redux/AppReducer';
import
*
as
globalActions
from
'
app/redux/GlobalReducer
'
;
import
*
as
transactionActions
from
'
app/redux/TransactionReducer
'
;
import
*
as
userActions
from
'
app/redux/UserReducer
'
;
import
*
as
proposalActions
from
'
app/redux/ProposalReducer
'
;
import
{
DEBT_TICKER
}
from
'
app/client_config
'
;
import
{
serverApiRecordEvent
}
from
'
app/utils/ServerApiClient
'
;
...
...
@@ -88,7 +89,7 @@ function* preBroadcast_update_proposal_votes({ operation, username }) {
if
(
!
operation
.
voter
)
operation
.
voter
=
username
;
const
{
voter
,
proposal_ids
}
=
operation
;
yield
put
(
glob
alActions
.
addActiveProposalVote
({
propos
alActions
.
addActiveProposalVote
({
voter
,
proposal_ids
,
})
...
...
@@ -375,7 +376,7 @@ function* accepted_update_proposal_votes({
});
yield
put
(
glob
alActions
.
removeActiveProposalVote
({
propos
alActions
.
removeActiveProposalVote
({
voter
,
proposal_ids
,
})
...
...
Write
Preview
Supports
Markdown
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