Repository: busyorg/busy
Pull request #2187 (2019-02-18 14:58:01)

feat: remove like post from editor
### Changes

Summary of the changes you made.

* Remove "Like this post" from the editor.

### Test plan

* [ ] Go to editor and check that there is no Like this post option.
* [ ] Create a new post to check that post is not upvoted.


jm90m: works for me tested on - https://busy-develop-pr-2187.herokuapp.com/@hellosteem/7vygkl-test

Patch:
diff --git a/src/client/components/Editor/Editor.js b/src/client/components/Editor/Editor.js
index 89edddb3..93c88913 100644
--- a/src/client/components/Editor/Editor.js
+++ b/src/client/components/Editor/Editor.js
@@ -30,7 +30,6 @@ class Editor extends React.Component {
     body: PropTypes.string,
     reward: PropTypes.string,
     beneficiary: PropTypes.bool,
-    upvote: PropTypes.bool,
     loading: PropTypes.bool,
     isUpdating: PropTypes.bool,
     saving: PropTypes.bool,
@@ -49,7 +48,6 @@ class Editor extends React.Component {
     body: '',
     reward: rewardsValues.half,
     beneficiary: true,
-    upvote: true,
     recentTopics: [],
     popularTopics: [],
     loading: false,
@@ -95,14 +93,14 @@ class Editor extends React.Component {
   }
 
   componentWillReceiveProps(nextProps) {
-    const { title, topics, body, reward, beneficiary, upvote, draftId } = this.props;
+    const { title, topics, body, reward, beneficiary, draftId } = this.props;
     if (
-      (title !== nextProps.title ||
-        !_.isEqual(topics, nextProps.topics) ||
-        body !== nextProps.body ||
-        reward !== nextProps.reward ||
-        beneficiary !== nextProps.beneficiary,
-      upvote !== nextProps.upvote || (draftId && nextProps.draftId === null))
+      title !== nextProps.title ||
+      !_.isEqual(topics, nextProps.topics) ||
+      body !== nextProps.body ||
+      reward !== nextProps.reward ||
+      beneficiary !== nextProps.beneficiary ||
+      (draftId && nextProps.draftId === null)
     ) {
       this.setValues(nextProps);
     }
@@ -130,7 +128,6 @@ class Editor extends React.Component {
       body: post.body,
       reward,
       beneficiary: post.beneficiary,
-      upvote: post.upvote,
     });
 
     this.setBodyAndRender(post.body);
@@ -371,13 +368,6 @@ class Editor extends React.Component {
             </Checkbox>,
           )}
         </Form.Item>
-        <Form.Item className={classNames({ Editor__hidden: isUpdating })}>
-          {getFieldDecorator('upvote', { valuePropName: 'checked', initialValue: true })(
-            <Checkbox onChange={this.onUpdate} disabled={isUpdating}>
-              <FormattedMessage id="like_post" defaultMessage="Like this post" />
-            </Checkbox>,
-          )}
-        </Form.Item>
         <div className="Editor__bottom">
           <span className="Editor__bottom__info">
             <i className="iconfont icon-markdown" />{' '}
diff --git a/src/client/components/QuickPostEditor/QuickPostEditor.js b/src/client/components/QuickPostEditor/QuickPostEditor.js
index 37164824..dd58bdfd 100644
--- a/src/client/components/QuickPostEditor/QuickPostEditor.js
+++ b/src/client/components/QuickPostEditor/QuickPostEditor.js
@@ -8,7 +8,7 @@ import _ from 'lodash';
 import { Input } from 'antd';
 import uuidv4 from 'uuid/v4';
 import { injectIntl, FormattedMessage } from 'react-intl';
-import { getAuthenticatedUser, getIsEditorLoading, getUpvoteSetting } from '../../reducers';
+import { getAuthenticatedUser, getIsEditorLoading } from '../../reducers';
 import { isValidImage, MAXIMUM_UPLOAD_SIZE } from '../../helpers/image';
 import { notify } from '../../app/Notification/notificationActions';
 import withEditor from '../Editor/withEditor';
@@ -26,7 +26,6 @@ const version = require('../../../../package.json').version;
   state => ({
     user: getAuthenticatedUser(state),
     postCreationLoading: getIsEditorLoading(state),
-    upvote: getUpvoteSetting(state),
   }),
   {
     notify,
@@ -43,7 +42,6 @@ class QuickPostEditor extends React.Component {
     createPost: PropTypes.func.isRequired,
     onImageUpload: PropTypes.func,
     onImageInvalid: PropTypes.func,
-    upvote: PropTypes.bool.isRequired,
   };
 
   static defaultProps = {
@@ -97,7 +95,6 @@ class QuickPostEditor extends React.Component {
       author: this.props.user.name,
       parentAuthor: '',
       lastUpdated: Date.now(),
-      upvote: this.props.upvote,
     };
 
     const metaData = {
diff --git a/src/client/locales/default.json b/src/client/locales/default.json
index 6f72be7d..25b9f167 100644
--- a/src/client/locales/default.json
+++ b/src/client/locales/default.json
@@ -208,7 +208,6 @@
   "reward_option_0": "Declined",
   "recommended_posts": "Recommended Posts",
   "add_busy_beneficiary": "Share {share}% of this post rewards with Busy",
-  "like_post": "Like this post",
   "saving": "Saving...",
   "post_send": "Post",
   "post_update_send": "Update post",
@@ -349,8 +348,6 @@
   "like_good_posts": "Like some good posts",
   "write_first_post": "Write your first post",
   "complete_profile_tooltip": "Must fill out the name, about, and profile picture fields",
-  "upvote_setting_details": "Enable this option to automatically like your own posts.",
-  "upvote_setting": "Like my posts",
   "dmca_content_removed": "Content removed due to DMCA notice",
   "beneficiaries": "Beneficiaries",
   "all": "All",
diff --git a/src/client/post/Write/Write.js b/src/client/post/Write/Write.js
index f7ca2e0b..0ff29135 100644
--- a/src/client/post/Write/Write.js
+++ b/src/client/post/Write/Write.js
@@ -18,7 +18,6 @@ import {
   getDraftPosts,
   getIsEditorLoading,
   getIsEditorSaving,
-  getUpvoteSetting,
   getRewardSetting,
 } from '../../reducers';
 
@@ -35,7 +34,6 @@ import Affix from '../../components/Utils/Affix';
     loading: getIsEditorLoading(state),
     saving: getIsEditorSaving(state),
     draftId: new URLSearchParams(props.location.search).get('draft'),
-    upvoteSetting: getUpvoteSetting(state),
     rewardSetting: getRewardSetting(state),
   }),
   {
@@ -53,7 +51,6 @@ class Write extends React.Component {
     intl: PropTypes.shape().isRequired,
     saving: PropTypes.bool,
     draftId: PropTypes.string,
-    upvoteSetting: PropTypes.bool,
     rewardSetting: PropTypes.string,
     newPost: PropTypes.func,
     createPost: PropTypes.func,
@@ -64,7 +61,6 @@ class Write extends React.Component {
   static defaultProps = {
     saving: false,
     draftId: null,
-    upvoteSetting: true,
     rewardSetting: rewardsValues.half,
     newPost: () => {},
     createPost: () => {},
@@ -81,7 +77,6 @@ class Write extends React.Component {
       initialBody: '',
       initialReward: this.props.rewardSetting,
       initialBeneficiary: true,
-      initialUpvote: this.props.upvoteSetting,
       initialUpdatedDate: Date.now(),
       isUpdating: false,
       showModalDelete: false,
@@ -115,7 +110,6 @@ class Write extends React.Component {
         initialReward: draftPost.reward,
         initialBeneficiary:
           typeof draftPost.beneficiary !== 'undefined' ? draftPost.beneficiary : true,
-        initialUpvote: draftPost.upvote,
         initialUpdatedDate: draftPost.lastUpdated || Date.now(),
         isUpdating: draftPost.isUpdating || false,
       });
@@ -139,20 +133,18 @@ class Write extends React.Component {
         initialBody: '',
         initialReward: rewardsValues.half,
         initialBeneficiary: true,
-        initialUpvote: nextProps.upvoteSetting,
         initialUpdatedDate: Date.now(),
         isUpdating: false,
         showModalDelete: false,
       });
     } else if (differentDraft) {
-      const { draftPosts, draftId, upvoteSetting } = nextProps;
+      const { draftPosts, draftId } = nextProps;
       const draftPost = _.get(draftPosts, draftId, {});
       const initialTitle = _.get(draftPost, 'title', '');
       const initialBody = _.get(draftPost, 'body', '');
       const initialTopics = _.get(draftPost, 'jsonMetadata.tags', []);
       const initialReward = _.get(draftPost, 'reward', rewardsValues.half);
       const initialBeneficiary = _.get(draftPost, 'beneficiary', true);
-      const initialUpvote = _.get(draftPost, 'upvote', upvoteSetting);
       this.draftId = draftId;
       this.setState({
         initialTitle,
@@ -160,7 +152,6 @@ class Write extends React.Component {
         initialTopics,
         initialReward,
         initialBeneficiary,
-        initialUpvote,
       });
     }
   }
@@ -190,7 +181,6 @@ class Write extends React.Component {
       title: form.title,
       reward: form.reward,
       beneficiary: form.beneficiary,
-      upvote: form.upvote,
       lastUpdated: Date.now(),
     };
 
@@ -243,7 +233,6 @@ class Write extends React.Component {
       initialBody,
       initialReward,
       initialBeneficiary,
-      initialUpvote,
     } = this.state;
     const { loading, saving, draftId } = this.props;
 
@@ -264,7 +253,6 @@ class Write extends React.Component {
               body={initialBody}
               reward={initialReward}
               beneficiary={initialBeneficiary}
-              upvote={initialUpvote}
               draftId={draftId}
               loading={loading}
               isUpdating={this.state.isUpdating}
diff --git a/src/client/post/Write/editorActions.js b/src/client/post/Write/editorActions.js
index b75ba256..a92db955 100644
--- a/src/client/post/Write/editorActions.js
+++ b/src/client/post/Write/editorActions.js
@@ -97,7 +97,6 @@ const broadcastComment = (
   jsonMetadata,
   reward,
   beneficiary,
-  upvote,
   permlink,
   referral,
   authUsername,
@@ -148,18 +147,6 @@ const broadcastComment = (
 
   operations.push(['comment_options', commentOptionsConfig]);
 
-  if (upvote) {
-    operations.push([
-      'vote',
-      {
-        voter: author,
-        author,
-        permlink,
-        weight: 10000,
-      },
-    ]);
-  }
-
   return steemConnectAPI.broadcast(operations);
 };
 
@@ -178,7 +165,6 @@ export function createPost(postData) {
       jsonMetadata,
       reward,
       beneficiary,
-      upvote,
       draftId,
       isUpdating,
     } = postData;
@@ -189,7 +175,7 @@ export function createPost(postData) {
     const authUser = state.auth.user;
     const newBody = isUpdating ? getBodyPatchIfSmaller(postData.originalBody, body) : body;
 
-    dispatch(saveSettings({ upvoteSetting: upvote, rewardSetting: reward }));
+    dispatch(saveSettings({ rewardSetting: reward }));
 
     let referral;
     if (Cookie.get('referral')) {
@@ -214,7 +200,6 @@ export function createPost(postData) {
             jsonMetadata,
             !isUpdating && reward,
             beneficiary,
-            !isUpdating && upvote,
             permlink,
             referral,
             authUser.name,
diff --git a/src/client/reducers.js b/src/client/reducers.js
index 8df34b7b..19180df7 100644
--- a/src/client/reducers.js
+++ b/src/client/reducers.js
@@ -124,7 +124,6 @@ export const getVotePercent = state => fromSettings.getVotePercent(state.setting
 export const getShowNSFWPosts = state => fromSettings.getShowNSFWPosts(state.settings);
 export const getNightmode = state => fromSettings.getNightmode(state.settings);
 export const getRewriteLinks = state => fromSettings.getRewriteLinks(state.settings);
-export const getUpvoteSetting = state => fromSettings.getUpvoteSetting(state.settings);
 export const getExitPageSetting = state => fromSettings.getExitPageSetting(state.settings);
 export const getRewardSetting = state => fromSettings.getRewardSetting(state.settings);
 export const getUseBeta = state => fromSettings.getUseBeta(state.settings);
diff --git a/src/client/settings/Settings.js b/src/client/settings/Settings.js
index 8a11cabf..834cf08d 100644
--- a/src/client/settings/Settings.js
+++ b/src/client/settings/Settings.js
@@ -14,7 +14,6 @@ import {
   getNightmode,
   getRewriteLinks,
   getUseBeta,
-  getUpvoteSetting,
   getExitPageSetting,
 } from '../reducers';
 import { saveSettings } from './settingsActions';
@@ -44,7 +43,6 @@ import packageJson from '../../../package.json';
     rewriteLinks: getRewriteLinks(state),
     useBeta: getUseBeta(state),
     loading: getIsSettingsLoading(state),
-    upvoteSetting: getUpvoteSetting(state),
     exitPageSetting: getExitPageSetting(state),
   }),
   { reload, saveSettings, notify },
@@ -64,7 +62,6 @@ export default class Settings extends React.Component {
     reload: PropTypes.func,
     saveSettings: PropTypes.func,
     notify: PropTypes.func,
-    upvoteSetting: PropTypes.bool,
     exitPageSetting: PropTypes.bool,
   };
 
@@ -78,18 +75,12 @@ export default class Settings extends React.Component {
     nightmode: false,
     rewriteLinks: false,
     useBeta: false,
-    upvoteSetting: true,
     exitPageSetting: true,
     reload: () => {},
     saveSettings: () => {},
     notify: () => {},
   };
 
-  constructor(props) {
-    super(props);
-    this.handleUpvoteSettingChange = this.handleUpvoteSettingChange.bind(this);
-  }
-
   state = {
     locale: 'auto',
     votingPower: 'auto',
@@ -109,7 +100,6 @@ export default class Settings extends React.Component {
       nightmode: this.props.nightmode,
       rewriteLinks: this.props.rewriteLinks,
       useBeta: this.props.useBeta,
-      upvoteSetting: this.props.upvoteSetting,
       exitPageSetting: this.props.exitPageSetting,
     });
   }
@@ -147,10 +137,6 @@ export default class Settings extends React.Component {
       this.setState({ useBeta: nextProps.useBeta });
     }
 
-    if (nextProps.upvoteSetting !== this.props.upvoteSetting) {
-      this.setState({ upvoteSetting: nextProps.upvoteSetting });
-    }
-
     if (nextProps.exitPageSetting !== this.props.exitPageSetting) {
       this.setState({ exitPageSetting: nextProps.exitPageSetting });
     }
@@ -166,7 +152,6 @@ export default class Settings extends React.Component {
         nightmode: this.state.nightmode,
         rewriteLinks: this.state.rewriteLinks,
         useBeta: this.state.useBeta,
-        upvoteSetting: this.state.upvoteSetting,
         exitPageSetting: this.state.exitPageSetting,
       })
       .then(() =>
@@ -186,10 +171,6 @@ export default class Settings extends React.Component {
   handleUseBetaChange = event => this.setState({ useBeta: event.target.checked });
   handleExitPageSettingChange = event => this.setState({ exitPageSetting: event.target.checked });
 
-  handleUpvoteSettingChange(event) {
-    this.setState({ upvoteSetting: event.target.checked });
-  }
-
   render() {
     const {
       intl,
@@ -207,7 +188,6 @@ export default class Settings extends React.Component {
       nightmode,
       rewriteLinks,
       useBeta,
-      upvoteSetting,
       exitPageSetting,
     } = this.state;
 
@@ -388,26 +368,6 @@ export default class Settings extends React.Component {
                     </Checkbox>
                   </div>
                 </div>
-                <div className="Settings__section">
-                  <h3>
-                    <FormattedMessage id="upvote_setting" defaultMessage="Like my posts" />
-                  </h3>
-                  <p>
-                    <FormattedMessage
-                      id="upvote_setting_details"
-                      defaultMessage="Enable this option to automatically like your own posts."
-                    />
-                  </p>
-                  <div className="Settings__section__checkbox">
-                    <Checkbox
-                      name="upvote_setting"
-                      checked={upvoteSetting}
-                      onChange={this.handleUpvoteSettingChange}
-                    >
-                      <FormattedMessage id="upvote_setting" defaultMessage="Like my posts" />
-                    </Checkbox>
-                  </div>
-                </div>
                 <div className="Settings__section">
                   <h3>
                     <FormattedMessage id="enable_exit_page" defaultMessage="Enable exit page" />
diff --git a/src/client/settings/settingsReducer.js b/src/client/settings/settingsReducer.js
index 9c355a0c..bfc79339 100644
--- a/src/client/settings/settingsReducer.js
+++ b/src/client/settings/settingsReducer.js
@@ -10,7 +10,6 @@ const initialState = {
   nightmode: false,
   rewriteLinks: false,
   loading: false,
-  upvoteSetting: true,
   exitPageSetting: true,
   rewardSetting: rewardsValues.half,
   useBeta: false,
@@ -29,7 +28,6 @@ const settings = (state = initialState, action) => {
           showNSFWPosts,
           nightmode,
           rewriteLinks,
-          upvoteSetting,
           exitPageSetting,
           rewardSetting,
           useBeta,
@@ -43,8 +41,6 @@ const settings = (state = initialState, action) => {
           nightmode: nightmode || initialState.nightmode,
           rewriteLinks:
             typeof rewriteLinks === 'boolean' ? rewriteLinks : initialState.rewriteLinks,
-          upvoteSetting:
-            typeof upvoteSetting === 'boolean' ? upvoteSetting : initialState.upvoteSetting,
           exitPageSetting:
             typeof exitPageSetting === 'boolean' ? exitPageSetting : initialState.exitPageSetting,
           rewardSetting: rewardSetting || initialState.rewardSetting,
@@ -67,7 +63,6 @@ const settings = (state = initialState, action) => {
         showNSFWPosts: action.payload.showNSFWPosts,
         nightmode: action.payload.nightmode,
         rewriteLinks: action.payload.rewriteLinks,
-        upvoteSetting: action.payload.upvoteSetting,
         exitPageSetting: action.payload.exitPageSetting,
         rewardSetting: action.payload.rewardSetting,
         useBeta: !!action.payload.useBeta,
@@ -96,7 +91,6 @@ export const getVotePercent = state => state.votePercent;
 export const getShowNSFWPosts = state => state.showNSFWPosts;
 export const getNightmode = state => state.nightmode;
 export const getRewriteLinks = state => !!state.rewriteLinks;
-export const getUpvoteSetting = state => state.upvoteSetting;
 export const getExitPageSetting = state => state.exitPageSetting;
 export const getRewardSetting = state => state.rewardSetting;
 export const getUseBeta = state => state.useBeta;


Test patch:
diff --git a/src/client/settings/__tests__/settingsReducer.js b/src/client/settings/__tests__/settingsReducer.js
index 81bdc42e..603befa7 100644
--- a/src/client/settings/__tests__/settingsReducer.js
+++ b/src/client/settings/__tests__/settingsReducer.js
@@ -13,7 +13,6 @@ describe('settingsReducer', () => {
     showNSFWPosts: false,
     nightmode: false,
     rewriteLinks: false,
-    upvoteSetting: true,
     exitPageSetting: true,
     rewardSetting: rewardsValues.half,
     useBeta: false,
@@ -88,7 +87,6 @@ describe('settingsReducer', () => {
         showNSFWPosts: true,
         nightmode: true,
         rewriteLinks: true,
-        upvoteSetting: true,
         exitPageSetting: true,
         rewardSetting: rewardsValues.half,
       },
@@ -103,7 +101,6 @@ describe('settingsReducer', () => {
       ...stateBefore,
       locale: 'fr',
       votingPower: 'off',
-      upvoteSetting: true,
       rewardSetting: rewardsValues.half,
     };
     const action = {
@@ -113,7 +110,6 @@ describe('settingsReducer', () => {
           settings: {
             locale: 'fr',
             votingPower: 'off',
-            upvoteSetting: true,
             rewardSetting: rewardsValues.half,
           },
         },
@@ -129,7 +125,6 @@ describe('settingsReducer', () => {
       ...stateBefore,
       locale: 'fr',
       votingPower: 'off',
-      upvoteSetting: false,
       rewardSetting: rewardsValues.none,
     };
     const action = {
@@ -139,7 +134,6 @@ describe('settingsReducer', () => {
           settings: {
             locale: 'fr',
             votingPower: 'off',
-            upvoteSetting: false,
             rewardSetting: rewardsValues.none,
           },
         },
@@ -179,7 +173,6 @@ describe('settingsReducer', () => {
           settings: {
             locale: 'fr',
             votingPower: 'off',
-            upvoteSetting: true,
             rewardSetting: rewardsValues.half,
           },
         },
@@ -195,7 +188,6 @@ describe('settingsReducer', () => {
       ...stateBefore,
       locale: 'fr',
       votingPower: 'off',
-      upvoteSetting: false,
       rewardSetting: rewardsValues.all,
     };
     const action = {
@@ -205,7 +197,6 @@ describe('settingsReducer', () => {
           settings: {
             locale: 'fr',
             votingPower: 'off',
-            upvoteSetting: false,
             rewardSetting: rewardsValues.all,
           },
         },