Skip to content

Commit

Permalink
Upgrade webpack minor and react minor releses steemit#192
Browse files Browse the repository at this point in the history
  • Loading branch information
James Calfee committed Aug 30, 2016
1 parent de7e226 commit 9580aae
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 195 deletions.
80 changes: 0 additions & 80 deletions app/redux/GlobalReducer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {Map, Set, List, fromJS, Iterable} from 'immutable';
import createModule from 'redux-modules';
import {PropTypes} from 'react';
import {emptyContent} from 'app/redux/EmptyState';
import constants from './constants';
import {contentStats} from 'app/utils/StateFunctions'

const {string, object, bool, array, oneOf, oneOfType, func, any} = PropTypes
const emptyContentMap = Map(emptyContent)

export default createModule({
Expand All @@ -24,7 +22,6 @@ export default createModule({
},
{
action: 'RECEIVE_STATE',
// payloadTypes: { },
reducer: (state, action) => {
// console.log('RECEIVE_STATE', action, state.toJS());
let payload = fromJS(action.payload)
Expand All @@ -44,9 +41,6 @@ export default createModule({
},
{
action: 'RECEIVE_ACCOUNT',
payloadTypes: {
account: object.isRequired,
},
reducer: (state, {payload: {account}}) => {
account = fromJS(account, (key, value) => {
if (key === 'witness_votes') return value.toSet()
Expand All @@ -59,14 +53,6 @@ export default createModule({
},
{
action: 'RECEIVE_COMMENT',
payloadTypes: {
author: string.isRequired,
permlink: string.isRequired,
body: object.isRequired, // Buffer
title: object, // Buffer
parent_permlink: string,
parent_author: string,
},
reducer: (state, {payload: op}) => {
const {author, permlink, parent_author = '', parent_permlink = '', title = '', body} = op
const key = author + '/' + permlink
Expand All @@ -88,9 +74,6 @@ export default createModule({
},
{
action: 'RECEIVE_CONTENT',
payloadTypes: {
content: object.isRequired, // full content object (replace from the blockchain)
},
reducer: (state, {payload: {content}}) => {
// console.log('GlobalReducer -- RECEIVE_CONTENT content', content)
content = fromJS(content)
Expand All @@ -106,12 +89,6 @@ export default createModule({
},
{ // works...
action: 'LINK_REPLY',
payloadTypes: {
author: string.isRequired,
permlink: string.isRequired,
parent_permlink: string,
parent_author: string,
},
reducer: (state, {payload: op}) => {
const {author, permlink, parent_author = '', parent_permlink = ''} = op
if (parent_author === '' || parent_permlink === '') return state
Expand All @@ -124,20 +101,12 @@ export default createModule({
},
{ // works...
action: 'UPDATE_ACCOUNT_WITNESS_VOTE',
payloadTypes: {
witness: string.isRequired,
approve: bool.isRequired,
},
reducer: (state, {payload: {account, witness, approve}}) =>
state.updateIn(['accounts', account, 'witness_votes'], Set(),
votes => (approve ? Set(votes).add(witness) : Set(votes).remove(witness)))
},
{
action: 'DELETE_CONTENT',
payloadTypes: {
author: string.isRequired,
permlink: string.isRequired,
},
reducer: (state, {payload: {author, permlink}}) => {
const key = author + '/' + permlink
const content = state.getIn(['content', key])
Expand Down Expand Up @@ -256,114 +225,65 @@ export default createModule({
},
{
action: 'REQUEST_META', // browser console debug
payloadTypes: {
id: string.isRequired,
link: string.isRequired,
},
reducer: (state, {payload: {id, link}}) =>
state.setIn(['metaLinkData', id], Map({link}))
},
{
action: 'RECEIVE_META', // browser console debug
payloadTypes: {
id: string.isRequired,
meta: object.isRequired,
},
reducer: (state, {payload: {id, meta}}) =>
state.updateIn(['metaLinkData', id], data => data.merge(meta))
},
{
action: 'SET',
payloadTypes: {
key: oneOfType([array, string]).isRequired,
value: any,
},
reducer: (state, {payload: {key, value}}) => {
key = Array.isArray(key) ? key : [key]
return state.setIn(key, fromJS(value))
}
},
{
action: 'REMOVE',
payloadTypes: {
key: oneOfType([array, string]).isRequired,
},
reducer: (state, {payload: {key}}) => {
key = Array.isArray(key) ? key : [key]
return state.removeIn(key)
}
},
{
action: 'UPDATE',
payloadTypes: {
key: any.isRequired,
notSet: any,
updater: any,
},
reducer: (state, {payload: {key, notSet = Map(), updater}}) =>
// key = Array.isArray(key) ? key : [key] // TODO enable and test
state.updateIn(key, notSet, updater)
},
{
action: 'SET_META_DATA', // browser console debug
payloadTypes: {
id: string.isRequired,
meta: object,
},
reducer: (state, {payload: {id, meta}}) =>
state.setIn(['metaLinkData', id], fromJS(meta))
},
{
action: 'CLEAR_META', // browser console debug
payloadTypes: {
id: string.isRequired,
},
reducer: (state, {payload: {id}}) =>
state.deleteIn(['metaLinkData', id])
},
{
action: 'CLEAR_META_ELEMENT', // browser console debug
payloadTypes: {
formId: string.isRequired,
element: oneOf(['description', 'image']).isRequired,
},
reducer: (state, {payload: {formId, element}}) =>
state.updateIn(['metaLinkData', formId], data => data.remove(element))
},
{
action: 'FETCH_JSON',
payloadTypes: {
id: string.isRequired,
url: string.isRequired,
body: object,
successCallback: func,
},
reducer: state => state // saga
},
{
action: 'FETCH_JSON_RESULT',
payloadTypes: {
id: string.isRequired,
result: any,
error: object,
},
reducer: (state, {payload: {id, result, error}}) =>
state.set(id, fromJS({result, error}))
},
{
action: 'SHOW_DIALOG',
payloadTypes: {
name: string.isRequired,
params: object,
},
reducer: (state, {payload: {name, params = {}}}) =>
state.update('active_dialogs', Map(), d => d.set(name, fromJS({params})))
},
{
action: 'HIDE_DIALOG',
payloadTypes: {
name: string.isRequired,
},
reducer: (state, {payload: {name}}) =>
state.update('active_dialogs', d => d.delete(name))
},
Expand Down
40 changes: 0 additions & 40 deletions app/redux/Transaction.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {fromJS, Map} from 'immutable';
import {PropTypes} from 'react';
import createModule from 'redux-modules';

const {string, object, array, bool, func, oneOfType, any} = PropTypes

export default createModule({
name: 'transaction',
initialState: fromJS({
Expand All @@ -14,11 +11,6 @@ export default createModule({
transformations: [
{
action: 'CONFIRM_OPERATION',
payloadTypes: {
operation: object,
confirm: oneOfType([string, func]),
errorCallback: func,
},
reducer: (state, {payload}) => {
const operation = fromJS(payload.operation)
const confirm = payload.confirm
Expand All @@ -36,16 +28,6 @@ export default createModule({
{
// An error will end up in QUEUE
action: 'BROADCAST_OPERATION',
payloadTypes: {
type: string.isRequired,
operation: object.isRequired,
confirm: oneOfType([string, func]), // confirmation message
successCallback: func,
errorCallback: func,
keys: array,
username: string,
password: string,
},
reducer: (state) => {//, {payload: {type, operation, keys}}
// See TransactionSaga.js
return state
Expand All @@ -54,24 +36,10 @@ export default createModule({
{
// An error will end up in QUEUE
action: 'UPDATE_AUTHORITIES',
payloadTypes: {
accountName: string.isRequired,
signingKey: string, // Required unless auths has password or WIF
auths: array.isRequired, // Auths may contain the signing key
twofa: bool,
onSuccess: func.isRequired,
onError: func.isRequired,
},
reducer: (state) => state,
},
{
action: 'ERROR',
payloadTypes: {
operations: array.isRequired,
keys: array.isRequired,
error: object.isRequired, /* only errors for now */
errorCallback: func,
},
reducer: (state, {payload: {operations, keys, error, errorCallback}}) => {
let errorStr = error.toString()
let errorKey = 'Transaction broadcast error.'
Expand Down Expand Up @@ -123,27 +91,19 @@ export default createModule({
},
{
action: 'DELETE_ERROR',
payloadTypes: {key: string.isRequired},
reducer: (state, {payload: {key}}) => {
return state.deleteIn(['errors', key]);
}
},
{
action: 'SET',
payloadTypes: {
key: oneOfType([array, string]).isRequired,
value: any,
},
reducer: (state, {payload: {key, value}}) => {
key = Array.isArray(key) ? key : [key]
return state.setIn(key, fromJS(value))
}
},
{
action: 'REMOVE',
payloadTypes: {
key: oneOfType([array, string]).isRequired,
},
reducer: (state, {payload: {key}}) => {
key = Array.isArray(key) ? key : [key]
return state.removeIn(key)
Expand Down
49 changes: 0 additions & 49 deletions app/redux/User.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {fromJS} from 'immutable';
import createModule from 'redux-modules';
import {PropTypes} from 'react';

const {string, object, bool, shape, oneOf} = PropTypes
const defaultState = fromJS({
current: null,
show_login_modal: false,
Expand All @@ -18,10 +16,6 @@ export default createModule({
transformations: [
{
action: 'SHOW_LOGIN',
payloadTypes: {
operation: object,
loginDefault: object,
},
reducer: (state, {payload}) => {
// https://github.com/mboperator/redux-modules/issues/11
if (typeof payload === 'function') payload = undefined
Expand Down Expand Up @@ -65,27 +59,10 @@ export default createModule({
{ action: 'CLEAR_TRANSFER_DEFAULTS', reducer: (state) => state.remove('transfer_defaults') },
{
action: 'USERNAME_PASSWORD_LOGIN',
payloadTypes: {
username: string,
password: string,
operationType: string,
saveLogin: bool,
},
reducer: state => state, // saga
},
{
action: 'SET_USER',
payloadTypes: {
username: string,
password: string,
account: object,
private_key: object,
private_keys: object,
login_owner_pubkey: string,
previous_owner_authority: object,
vesting_shares: string,
// pending_private_key: object,
},
reducer: (state, {payload}) => {
// console.log('SET_USER')
if (payload.vesting_shares) payload.vesting_shares = parseFloat(payload.vesting_shares);
Expand All @@ -94,16 +71,10 @@ export default createModule({
},
{
action: 'CLOSE_LOGIN',
payloadTypes: {
error: string,
},
reducer: (state) => state.merge({ login_error: undefined, show_login_modal: false, loginBroadcastOperation: undefined, loginDefault: undefined })
},
{
action: 'LOGIN_ERROR',
payloadTypes: {
error: string,
},
reducer: (state, {payload: {error}}) => state.merge({ login_error: error, logged_out: undefined })
},
{
Expand All @@ -122,37 +93,17 @@ export default createModule({

{
action: 'KEYS_ERROR',
payloadTypes: {
error: string,
},
reducer: (state, {payload: {error}}) => state.merge({ keys_error: error })
},
// { action: 'UPDATE_PERMISSIONS', reducer: state => {
// return state // saga
// }},
{ // AuthSaga
action: 'ACCOUNT_AUTH_LOOKUP',
payloadTypes: {
account: object.isRequired, // immutable Map
private_keys: shape({
posting_private: object,
active_private: object,
}), // Immutable Map
login_owner_pubkey: string,
},
reducer: state => state
},
{ // AuthSaga
action: 'SET_AUTHORITY',
payloadTypes: {
accountName: string.isRequired,
auth: shape({
posting: oneOf(['full', 'partial', 'none']),
active: oneOf(['full', 'partial', 'none']),
owner: oneOf(['full', 'partial', 'none']),
}).isRequired, // Immutable Set
pub_keys_used: object,
},
reducer: (state, {payload: {accountName, auth, pub_keys_used}}) => {
state = state.setIn(['authority', accountName], fromJS(auth))
if(pub_keys_used)
Expand Down
Loading

0 comments on commit 9580aae

Please sign in to comment.