diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-11-03 16:57:44 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-11-03 16:57:44 +0100 |
commit | 3731230c6d25f248afa8a17b62b3db70fdfe1e03 (patch) | |
tree | 9e7da1198a5e20c600add1cad4c0c288c524d1f9 /app/assets/javascripts/components | |
parent | e4671adc25081161268c885b3427fd84cbecb249 (diff) |
Allow @username@domain/@username in follow form, prevent duplicate accounts
created via remote look-up when domains differ but point to the same resource
Diffstat (limited to 'app/assets/javascripts/components')
3 files changed, 19 insertions, 19 deletions
diff --git a/app/assets/javascripts/components/reducers/accounts.jsx b/app/assets/javascripts/components/reducers/accounts.jsx index 10d637e57..bc2144752 100644 --- a/app/assets/javascripts/components/reducers/accounts.jsx +++ b/app/assets/javascripts/components/reducers/accounts.jsx @@ -25,7 +25,7 @@ import { } from '../actions/statuses'; import Immutable from 'immutable'; -const normalizeAccount = (state, account) => state.set(account.get('id'), account); +const normalizeAccount = (state, account) => state.set(account.id, Immutable.fromJS(account)); const normalizeAccounts = (state, accounts) => { accounts.forEach(account => { @@ -36,10 +36,10 @@ const normalizeAccounts = (state, accounts) => { }; const normalizeAccountFromStatus = (state, status) => { - state = normalizeAccount(state, status.get('account')); + state = normalizeAccount(state, status.account); - if (status.getIn(['reblog', 'account'])) { - state = normalizeAccount(state, status.getIn(['reblog', 'account'])); + if (status.reblog && status.reblog.account) { + state = normalizeAccount(state, status.reblog.account); } return state; @@ -60,24 +60,24 @@ export default function accounts(state = initialState, action) { case ACCOUNT_SET_SELF: case ACCOUNT_FETCH_SUCCESS: case FOLLOW_SUBMIT_SUCCESS: - return normalizeAccount(state, Immutable.fromJS(action.account)); + return normalizeAccount(state, action.account); case SUGGESTIONS_FETCH_SUCCESS: case FOLLOWERS_FETCH_SUCCESS: case FOLLOWING_FETCH_SUCCESS: - return normalizeAccounts(state, Immutable.fromJS(action.accounts)); + return normalizeAccounts(state, action.accounts); case TIMELINE_REFRESH_SUCCESS: case TIMELINE_EXPAND_SUCCESS: case ACCOUNT_TIMELINE_FETCH_SUCCESS: case ACCOUNT_TIMELINE_EXPAND_SUCCESS: case CONTEXT_FETCH_SUCCESS: - return normalizeAccountsFromStatuses(state, Immutable.fromJS(action.statuses)); + return normalizeAccountsFromStatuses(state, action.statuses); case TIMELINE_UPDATE: case REBLOG_SUCCESS: case FAVOURITE_SUCCESS: case UNREBLOG_SUCCESS: case UNFAVOURITE_SUCCESS: case STATUS_FETCH_SUCCESS: - return normalizeAccountFromStatus(state, Immutable.fromJS(action.status)); + return normalizeAccountFromStatus(state, action.status); default: return state; } diff --git a/app/assets/javascripts/components/reducers/relationships.jsx b/app/assets/javascripts/components/reducers/relationships.jsx index 165b1f3ff..e4af1f028 100644 --- a/app/assets/javascripts/components/reducers/relationships.jsx +++ b/app/assets/javascripts/components/reducers/relationships.jsx @@ -7,7 +7,7 @@ import { } from '../actions/accounts'; import Immutable from 'immutable'; -const normalizeRelationship = (state, relationship) => state.set(relationship.get('id'), relationship); +const normalizeRelationship = (state, relationship) => state.set(relationship.id, Immutable.fromJS(relationship)); const normalizeRelationships = (state, relationships) => { relationships.forEach(relationship => { @@ -25,9 +25,9 @@ export default function relationships(state = initialState, action) { case ACCOUNT_UNFOLLOW_SUCCESS: case ACCOUNT_BLOCK_SUCCESS: case ACCOUNT_UNBLOCK_SUCCESS: - return normalizeRelationship(state, Immutable.fromJS(action.relationship)); + return normalizeRelationship(state, action.relationship); case RELATIONSHIPS_FETCH_SUCCESS: - return normalizeRelationships(state, Immutable.fromJS(action.relationships)); + return normalizeRelationships(state, action.relationships); default: return state; } diff --git a/app/assets/javascripts/components/reducers/statuses.jsx b/app/assets/javascripts/components/reducers/statuses.jsx index a1f1f07f1..69c0e6193 100644 --- a/app/assets/javascripts/components/reducers/statuses.jsx +++ b/app/assets/javascripts/components/reducers/statuses.jsx @@ -21,14 +21,14 @@ import { import Immutable from 'immutable'; const normalizeStatus = (state, status) => { - status = status.set('account', status.getIn(['account', 'id'])); + status.account = status.account.id; - if (status.getIn(['reblog', 'id'])) { - state = normalizeStatus(state, status.get('reblog')); - status = status.set('reblog', status.getIn(['reblog', 'id'])); + if (status.reblog && status.reblog.id) { + state = normalizeStatus(state, status.reblog); + status.reblog = status.reblog.id; } - return state.set(status.get('id'), status); + return state.set(status.id, Immutable.fromJS(status)); }; const normalizeStatuses = (state, statuses) => { @@ -53,18 +53,18 @@ export default function statuses(state = initialState, action) { switch(action.type) { case TIMELINE_UPDATE: case STATUS_FETCH_SUCCESS: - return normalizeStatus(state, Immutable.fromJS(action.status)); + return normalizeStatus(state, action.status); case REBLOG_SUCCESS: case UNREBLOG_SUCCESS: case FAVOURITE_SUCCESS: case UNFAVOURITE_SUCCESS: - return normalizeStatus(state, Immutable.fromJS(action.response)); + return normalizeStatus(state, action.response); case TIMELINE_REFRESH_SUCCESS: case TIMELINE_EXPAND_SUCCESS: case ACCOUNT_TIMELINE_FETCH_SUCCESS: case ACCOUNT_TIMELINE_EXPAND_SUCCESS: case CONTEXT_FETCH_SUCCESS: - return normalizeStatuses(state, Immutable.fromJS(action.statuses)); + return normalizeStatuses(state, action.statuses); case TIMELINE_DELETE: return deleteStatus(state, action.id, action.references); default: |