about summary refs log tree commit diff
path: root/app/assets
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/components/actions/accounts.jsx8
-rw-r--r--app/assets/javascripts/components/components/button.jsx19
-rw-r--r--app/assets/javascripts/components/components/status.jsx1
-rw-r--r--app/assets/javascripts/components/components/status_action_bar.jsx9
-rw-r--r--app/assets/javascripts/components/containers/mastodon.jsx5
-rw-r--r--app/assets/javascripts/components/containers/status_container.jsx17
-rw-r--r--app/assets/javascripts/components/features/account/components/action_bar.jsx2
-rw-r--r--app/assets/javascripts/components/features/account/components/header.jsx25
-rw-r--r--app/assets/javascripts/components/features/account/index.jsx5
-rw-r--r--app/assets/javascripts/components/features/compose/components/compose_form.jsx4
-rw-r--r--app/assets/javascripts/components/locales/en.jsx3
-rw-r--r--app/assets/javascripts/components/reducers/notifications.jsx7
-rw-r--r--app/assets/javascripts/components/reducers/statuses.jsx29
-rw-r--r--app/assets/javascripts/components/reducers/timelines.jsx20
14 files changed, 120 insertions, 34 deletions
diff --git a/app/assets/javascripts/components/actions/accounts.jsx b/app/assets/javascripts/components/actions/accounts.jsx
index 4a0777a64..759435afe 100644
--- a/app/assets/javascripts/components/actions/accounts.jsx
+++ b/app/assets/javascripts/components/actions/accounts.jsx
@@ -246,7 +246,8 @@ export function blockAccount(id) {
     dispatch(blockAccountRequest(id));
 
     api(getState).post(`/api/v1/accounts/${id}/block`).then(response => {
-      dispatch(blockAccountSuccess(response.data));
+      // Pass in entire statuses map so we can use it to filter stuff in different parts of the reducers
+      dispatch(blockAccountSuccess(response.data, getState().get('statuses')));
     }).catch(error => {
       dispatch(blockAccountFail(id, error));
     });
@@ -272,10 +273,11 @@ export function blockAccountRequest(id) {
   };
 };
 
-export function blockAccountSuccess(relationship) {
+export function blockAccountSuccess(relationship, statuses) {
   return {
     type: ACCOUNT_BLOCK_SUCCESS,
-    relationship
+    relationship,
+    statuses
   };
 };
 
diff --git a/app/assets/javascripts/components/components/button.jsx b/app/assets/javascripts/components/components/button.jsx
index fe36d40c5..d63129013 100644
--- a/app/assets/javascripts/components/components/button.jsx
+++ b/app/assets/javascripts/components/components/button.jsx
@@ -7,7 +7,14 @@ const Button = React.createClass({
     onClick: React.PropTypes.func,
     disabled: React.PropTypes.bool,
     block: React.PropTypes.bool,
-    secondary: React.PropTypes.bool
+    secondary: React.PropTypes.bool,
+    size: React.PropTypes.number,
+  },
+
+  getDefaultProps () {
+    return {
+      size: 36
+    };
   },
 
   mixins: [PureRenderMixin],
@@ -32,16 +39,16 @@ const Button = React.createClass({
       fontWeight: '500',
       letterSpacing: '0',
       textTransform: 'uppercase',
-      padding: '0 16px',
-      height: '36px',
+      padding: `0 ${this.props.size / 2.25}px`,
+      height: `${this.props.size}px`,
       cursor: 'pointer',
-      lineHeight: '36px',
+      lineHeight: `${this.props.size}px`,
       borderRadius: '4px',
       textDecoration: 'none'
     };
-    
+
     return (
-      <button className={`button ${this.props.secondary ? 'button-secondary' : ''}`} disabled={this.props.disabled} onClick={this.handleClick} style={style}>
+      <button className={`button ${this.props.secondary ? 'button-secondary' : ''}`} disabled={this.props.disabled} onClick={this.handleClick} style={{ ...style, ...this.props.style }}>
         {this.props.text || this.props.children}
       </button>
     );
diff --git a/app/assets/javascripts/components/components/status.jsx b/app/assets/javascripts/components/components/status.jsx
index bf851e5bf..603561ab3 100644
--- a/app/assets/javascripts/components/components/status.jsx
+++ b/app/assets/javascripts/components/components/status.jsx
@@ -34,6 +34,7 @@ const Status = React.createClass({
     onReblog: React.PropTypes.func,
     onDelete: React.PropTypes.func,
     onOpenMedia: React.PropTypes.func,
+    onBlock: React.PropTypes.func,
     me: React.PropTypes.number,
     muted: React.PropTypes.bool
   },
diff --git a/app/assets/javascripts/components/components/status_action_bar.jsx b/app/assets/javascripts/components/components/status_action_bar.jsx
index dec1decff..35feda88b 100644
--- a/app/assets/javascripts/components/components/status_action_bar.jsx
+++ b/app/assets/javascripts/components/components/status_action_bar.jsx
@@ -7,6 +7,7 @@ import { defineMessages, injectIntl } from 'react-intl';
 const messages = defineMessages({
   delete: { id: 'status.delete', defaultMessage: 'Delete' },
   mention: { id: 'status.mention', defaultMessage: 'Mention' },
+  block: { id: 'account.block', defaultMessage: 'Block' },
   reply: { id: 'status.reply', defaultMessage: 'Reply' },
   reblog: { id: 'status.reblog', defaultMessage: 'Reblog' },
   favourite: { id: 'status.favourite', defaultMessage: 'Favourite' }
@@ -24,7 +25,8 @@ const StatusActionBar = React.createClass({
     onFavourite: React.PropTypes.func,
     onReblog: React.PropTypes.func,
     onDelete: React.PropTypes.func,
-    onMention: React.PropTypes.func
+    onMention: React.PropTypes.func,
+    onBlock: React.PropTypes.func
   },
 
   mixins: [PureRenderMixin],
@@ -49,6 +51,10 @@ const StatusActionBar = React.createClass({
     this.props.onMention(this.props.status.get('account'));
   },
 
+  handleBlockClick () {
+    this.props.onBlock(this.props.status.get('account'));
+  },
+
   render () {
     const { status, me, intl } = this.props;
     let menu = [];
@@ -57,6 +63,7 @@ const StatusActionBar = React.createClass({
       menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick });
     } else {
       menu.push({ text: intl.formatMessage(messages.mention), action: this.handleMentionClick });
+      menu.push({ text: intl.formatMessage(messages.block), action: this.handleBlockClick });
     }
 
     return (
diff --git a/app/assets/javascripts/components/containers/mastodon.jsx b/app/assets/javascripts/components/containers/mastodon.jsx
index 87c7c65f3..c9f037ec2 100644
--- a/app/assets/javascripts/components/containers/mastodon.jsx
+++ b/app/assets/javascripts/components/containers/mastodon.jsx
@@ -75,11 +75,6 @@ const Mastodon = React.createClass({
               return store.dispatch(updateTimeline(data.timeline, JSON.parse(data.message)));
             case 'delete':
               return store.dispatch(deleteFromTimelines(data.id));
-            case 'merge':
-            case 'unmerge':
-              return store.dispatch(refreshTimeline('home', true));
-            case 'block':
-              return store.dispatch(refreshTimeline('mentions', true));
             case 'notification':
               return store.dispatch(updateNotifications(JSON.parse(data.message), getMessagesForLocale(locale), locale));
           }
diff --git a/app/assets/javascripts/components/containers/status_container.jsx b/app/assets/javascripts/components/containers/status_container.jsx
index 28756b5ef..6a882eab4 100644
--- a/app/assets/javascripts/components/containers/status_container.jsx
+++ b/app/assets/javascripts/components/containers/status_container.jsx
@@ -1,18 +1,19 @@
-import { connect }       from 'react-redux';
-import Status            from '../components/status';
+import { connect } from 'react-redux';
+import Status from '../components/status';
 import { makeGetStatus } from '../selectors';
 import {
   replyCompose,
   mentionCompose
-}                        from '../actions/compose';
+} from '../actions/compose';
 import {
   reblog,
   favourite,
   unreblog,
   unfavourite
-}                        from '../actions/interactions';
-import { deleteStatus }  from '../actions/statuses';
-import { openMedia }     from '../actions/modal';
+} from '../actions/interactions';
+import { blockAccount } from '../actions/accounts';
+import { deleteStatus } from '../actions/statuses';
+import { openMedia } from '../actions/modal';
 import { createSelector } from 'reselect'
 
 const mapStateToProps = (state, props) => ({
@@ -91,6 +92,10 @@ const mapDispatchToProps = (dispatch) => ({
 
   onOpenMedia (url) {
     dispatch(openMedia(url));
+  },
+
+  onBlock (account) {
+    dispatch(blockAccount(account.get('id')));
   }
 
 });
diff --git a/app/assets/javascripts/components/features/account/components/action_bar.jsx b/app/assets/javascripts/components/features/account/components/action_bar.jsx
index cd01de2e2..f09dea6ab 100644
--- a/app/assets/javascripts/components/features/account/components/action_bar.jsx
+++ b/app/assets/javascripts/components/features/account/components/action_bar.jsx
@@ -58,10 +58,8 @@ const ActionBar = React.createClass({
     } else if (account.getIn(['relationship', 'blocking'])) {
       menu.push({ text: intl.formatMessage(messages.unblock), action: this.props.onBlock });
     } else if (account.getIn(['relationship', 'following'])) {
-      menu.push({ text: intl.formatMessage(messages.unfollow), action: this.props.onFollow });
       menu.push({ text: intl.formatMessage(messages.block), action: this.props.onBlock });
     } else {
-      menu.push({ text: intl.formatMessage(messages.follow), action: this.props.onFollow });
       menu.push({ text: intl.formatMessage(messages.block), action: this.props.onBlock });
     }
 
diff --git a/app/assets/javascripts/components/features/account/components/header.jsx b/app/assets/javascripts/components/features/account/components/header.jsx
index b3e9e2a9f..d39a06062 100644
--- a/app/assets/javascripts/components/features/account/components/header.jsx
+++ b/app/assets/javascripts/components/features/account/components/header.jsx
@@ -2,22 +2,30 @@ import PureRenderMixin from 'react-addons-pure-render-mixin';
 import ImmutablePropTypes from 'react-immutable-proptypes';
 import emojify from '../../../emoji';
 import escapeTextContentForBrowser from 'react/lib/escapeTextContentForBrowser';
-import { FormattedMessage } from 'react-intl';
+import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
+import IconButton from '../../../components/icon_button';
+
+const messages = defineMessages({
+  unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
+  follow: { id: 'account.follow', defaultMessage: 'Follow' },
+});
 
 const Header = React.createClass({
 
   propTypes: {
     account: ImmutablePropTypes.map.isRequired,
-    me: React.PropTypes.number.isRequired
+    me: React.PropTypes.number.isRequired,
+    onFollow: React.PropTypes.func.isRequired
   },
 
   mixins: [PureRenderMixin],
 
   render () {
-    const { account, me } = this.props;
+    const { account, me, intl } = this.props;
 
     let displayName = account.get('display_name');
     let info        = '';
+    let actionBtn   = '';
 
     if (displayName.length === 0) {
       displayName = account.get('username');
@@ -27,6 +35,14 @@ const Header = React.createClass({
       info = <span style={{ position: 'absolute', top: '10px', right: '10px', opacity: '0.7', display: 'inline-block', verticalAlign: 'top', background: 'rgba(0, 0, 0, 0.4)', color: '#fff', textTransform: 'uppercase', fontSize: '11px', fontWeight: '500', padding: '4px', borderRadius: '4px' }}><FormattedMessage id='account.follows_you' defaultMessage='Follows you' /></span>
     }
 
+    if (me !== account.get('id')) {
+      actionBtn = (
+        <div style={{ position: 'absolute', top: '10px', left: '20px' }}>
+          <IconButton size={26} icon={account.getIn(['relationship', 'following']) ? 'user-times' : 'user-plus'} active={account.getIn(['relationship', 'following'])} title={intl.formatMessage(account.getIn(['relationship', 'following']) ? messages.unfollow : messages.follow)} onClick={this.props.onFollow} />
+        </div>
+      );
+    }
+
     const content         = { __html: emojify(account.get('note')) };
     const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) };
 
@@ -45,6 +61,7 @@ const Header = React.createClass({
           <div style={{ color: '#616b86', fontSize: '14px' }} className='account__header__content' dangerouslySetInnerHTML={content} />
 
           {info}
+          {actionBtn}
         </div>
       </div>
     );
@@ -52,4 +69,4 @@ const Header = React.createClass({
 
 });
 
-export default Header;
+export default injectIntl(Header);
diff --git a/app/assets/javascripts/components/features/account/index.jsx b/app/assets/javascripts/components/features/account/index.jsx
index 818979f8f..c2cc58bb2 100644
--- a/app/assets/javascripts/components/features/account/index.jsx
+++ b/app/assets/javascripts/components/features/account/index.jsx
@@ -87,9 +87,8 @@ const Account = React.createClass({
     return (
       <Column>
         <ColumnBackButton />
-        <Header account={account} me={me} />
-
-        <ActionBar account={account} me={me} onFollow={this.handleFollow} onBlock={this.handleBlock} onMention={this.handleMention} />
+        <Header account={account} me={me} onFollow={this.handleFollow} />
+        <ActionBar account={account} me={me} onBlock={this.handleBlock} onMention={this.handleMention} />
 
         {this.props.children}
       </Column>
diff --git a/app/assets/javascripts/components/features/compose/components/compose_form.jsx b/app/assets/javascripts/components/features/compose/components/compose_form.jsx
index 7c42e481d..5ad1ca172 100644
--- a/app/assets/javascripts/components/features/compose/components/compose_form.jsx
+++ b/app/assets/javascripts/components/features/compose/components/compose_form.jsx
@@ -8,7 +8,7 @@ import Autosuggest from 'react-autosuggest';
 import AutosuggestAccountContainer from '../../compose/containers/autosuggest_account_container';
 import { debounce } from 'react-decoration';
 import UploadButtonContainer from '../containers/upload_button_container';
-import { defineMessages, injectIntl } from 'react-intl';
+import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
 import Toggle from 'react-toggle';
 
 const messages = defineMessages({
@@ -188,7 +188,7 @@ const ComposeForm = React.createClass({
 
         <label style={{ display: 'block', lineHeight: '24px', verticalAlign: 'middle', marginTop: '10px', borderTop: '1px solid #616b86', paddingTop: '10px' }}>
           <Toggle checked={this.props.sensitive} onChange={this.handleChangeSensitivity} />
-          <span style={{ display: 'inline-block', verticalAlign: 'middle', marginBottom: '14px', marginLeft: '8px', color: '#9baec8' }}>Sensitive content</span>
+          <span style={{ display: 'inline-block', verticalAlign: 'middle', marginBottom: '14px', marginLeft: '8px', color: '#9baec8' }}><FormattedMessage id='compose_form.sensitive' defaultMessage='Mark content as sensitive' /></span>
         </label>
       </div>
     );
diff --git a/app/assets/javascripts/components/locales/en.jsx b/app/assets/javascripts/components/locales/en.jsx
index f3326bf90..0ea324f66 100644
--- a/app/assets/javascripts/components/locales/en.jsx
+++ b/app/assets/javascripts/components/locales/en.jsx
@@ -8,6 +8,8 @@ const en = {
   "status.reblog": "Reblog",
   "status.favourite": "Favourite",
   "status.reblogged_by": "{name} reblogged",
+  "status.sensitive_warning": "Sensitive content",
+  "status.sensitive_toggle": "Click to view",
   "video_player.toggle_sound": "Toggle sound",
   "account.mention": "Mention",
   "account.edit_profile": "Edit profile",
@@ -35,6 +37,7 @@ const en = {
   "tabs_bar.notifications": "Notifications",
   "compose_form.placeholder": "What is on your mind?",
   "compose_form.publish": "Toot",
+  "compose_form.sensitive": "Mark content as sensitive",
   "navigation_bar.settings": "Settings",
   "navigation_bar.public_timeline": "Public timeline",
   "navigation_bar.logout": "Logout",
diff --git a/app/assets/javascripts/components/reducers/notifications.jsx b/app/assets/javascripts/components/reducers/notifications.jsx
index 0e67e732a..617a833d2 100644
--- a/app/assets/javascripts/components/reducers/notifications.jsx
+++ b/app/assets/javascripts/components/reducers/notifications.jsx
@@ -3,6 +3,7 @@ import {
   NOTIFICATIONS_REFRESH_SUCCESS,
   NOTIFICATIONS_EXPAND_SUCCESS
 } from '../actions/notifications';
+import { ACCOUNT_BLOCK_SUCCESS } from '../actions/accounts';
 import Immutable from 'immutable';
 
 const initialState = Immutable.Map({
@@ -43,6 +44,10 @@ const appendNormalizedNotifications = (state, notifications, next) => {
   return state.update('items', list => list.push(...items)).set('next', next);
 };
 
+const filterNotifications = (state, relationship) => {
+  return state.update('items', list => list.filterNot(item => item.get('account') === relationship.id));
+};
+
 export default function notifications(state = initialState, action) {
   switch(action.type) {
     case NOTIFICATIONS_UPDATE:
@@ -51,6 +56,8 @@ export default function notifications(state = initialState, action) {
       return normalizeNotifications(state, action.notifications, action.next);
     case NOTIFICATIONS_EXPAND_SUCCESS:
       return appendNormalizedNotifications(state, action.notifications, action.next);
+    case ACCOUNT_BLOCK_SUCCESS:
+      return filterNotifications(state, action.relationship);
     default:
       return state;
   }
diff --git a/app/assets/javascripts/components/reducers/statuses.jsx b/app/assets/javascripts/components/reducers/statuses.jsx
index 2a24a75e4..c740b6d64 100644
--- a/app/assets/javascripts/components/reducers/statuses.jsx
+++ b/app/assets/javascripts/components/reducers/statuses.jsx
@@ -1,7 +1,11 @@
 import {
+  REBLOG_REQUEST,
   REBLOG_SUCCESS,
+  REBLOG_FAIL,
   UNREBLOG_SUCCESS,
+  FAVOURITE_REQUEST,
   FAVOURITE_SUCCESS,
+  FAVOURITE_FAIL,
   UNFAVOURITE_SUCCESS
 } from '../actions/interactions';
 import {
@@ -16,7 +20,8 @@ import {
 } from '../actions/timelines';
 import {
   ACCOUNT_TIMELINE_FETCH_SUCCESS,
-  ACCOUNT_TIMELINE_EXPAND_SUCCESS
+  ACCOUNT_TIMELINE_EXPAND_SUCCESS,
+  ACCOUNT_BLOCK_SUCCESS
 } from '../actions/accounts';
 import {
   NOTIFICATIONS_UPDATE,
@@ -56,6 +61,18 @@ const deleteStatus = (state, id, references) => {
   return state.delete(id);
 };
 
+const filterStatuses = (state, relationship) => {
+  state.forEach(status => {
+    if (status.get('account') !== relationship.id) {
+      return;
+    }
+
+    state = deleteStatus(state, status.get('id'), state.filter(item => item.get('reblog') === status.get('id')));
+  });
+
+  return state;
+};
+
 const initialState = Immutable.Map();
 
 export default function statuses(state = initialState, action) {
@@ -69,6 +86,14 @@ export default function statuses(state = initialState, action) {
     case FAVOURITE_SUCCESS:
     case UNFAVOURITE_SUCCESS:
       return normalizeStatus(state, action.response);
+    case FAVOURITE_REQUEST:
+      return state.setIn([action.status.get('id'), 'favourited'], true);
+    case FAVOURITE_FAIL:
+      return state.setIn([action.status.get('id'), 'favourited'], false);
+    case REBLOG_REQUEST:
+      return state.setIn([action.status.get('id'), 'reblogged'], true);
+    case REBLOG_FAIL:
+      return state.setIn([action.status.get('id'), 'reblogged'], false);
     case TIMELINE_REFRESH_SUCCESS:
     case TIMELINE_EXPAND_SUCCESS:
     case ACCOUNT_TIMELINE_FETCH_SUCCESS:
@@ -79,6 +104,8 @@ export default function statuses(state = initialState, action) {
       return normalizeStatuses(state, action.statuses);
     case TIMELINE_DELETE:
       return deleteStatus(state, action.id, action.references);
+    case ACCOUNT_BLOCK_SUCCESS:
+      return filterStatuses(state, action.relationship);
     default:
       return state;
   }
diff --git a/app/assets/javascripts/components/reducers/timelines.jsx b/app/assets/javascripts/components/reducers/timelines.jsx
index 9e79a4100..358734eaf 100644
--- a/app/assets/javascripts/components/reducers/timelines.jsx
+++ b/app/assets/javascripts/components/reducers/timelines.jsx
@@ -13,7 +13,8 @@ import {
 import {
   ACCOUNT_FETCH_SUCCESS,
   ACCOUNT_TIMELINE_FETCH_SUCCESS,
-  ACCOUNT_TIMELINE_EXPAND_SUCCESS
+  ACCOUNT_TIMELINE_EXPAND_SUCCESS,
+  ACCOUNT_BLOCK_SUCCESS
 } from '../actions/accounts';
 import {
   STATUS_FETCH_SUCCESS,
@@ -140,6 +141,21 @@ const deleteStatus = (state, id, accountId, references) => {
   return state;
 };
 
+const filterTimelines = (state, relationship, statuses) => {
+  let references;
+
+  statuses.forEach(status => {
+    if (status.get('account') !== relationship.id) {
+      return;
+    }
+
+    references = statuses.filter(item => item.get('reblog') === status.get('id')).map(item => [item.get('id'), item.get('account')]);
+    state = deleteStatus(state, status.get('id'), status.get('account'), references);
+  });
+
+  return state;
+};
+
 const normalizeContext = (state, id, ancestors, descendants) => {
   const ancestorsIds   = ancestors.map(ancestor => ancestor.get('id'));
   const descendantsIds = descendants.map(descendant => descendant.get('id'));
@@ -166,6 +182,8 @@ export default function timelines(state = initialState, action) {
       return normalizeAccountTimeline(state, action.id, Immutable.fromJS(action.statuses), action.replace);
     case ACCOUNT_TIMELINE_EXPAND_SUCCESS:
       return appendNormalizedAccountTimeline(state, action.id, Immutable.fromJS(action.statuses));
+    case ACCOUNT_BLOCK_SUCCESS:
+      return filterTimelines(state, action.relationship, action.statuses);
     default:
       return state;
   }