Skip to content

Commit

Permalink
Merge pull request #2914 from ecency/nt/beneficiary-extraction
Browse files Browse the repository at this point in the history
Nt/beneficiary extraction
  • Loading branch information
feruzm authored Aug 27, 2024
2 parents 47289ce + b5f6532 commit b64c750
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/screens/editor/container/editorContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ class EditorContainer extends Component<EditorContainerProps, any> {
fields,
scheduleDate,
jsonMeta,
beneficiaries,
});
} else {
await postContent(
Expand Down Expand Up @@ -1188,13 +1189,12 @@ class EditorContainer extends Component<EditorContainerProps, any> {
_setScheduledPost = (data) => {
const { dispatch, intl, currentAccount, navigation } = this.props;
const { rewardType } = this.state;
const beneficiaries = this._extractBeneficiaries();

const options = makeOptions({
author: data.author,
permlink: data.permlink,
operationType: rewardType,
beneficiaries,
beneficiaries: data.beneficiaries,
});

addSchedule(
Expand Down
21 changes: 8 additions & 13 deletions src/utils/editor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { diff_match_patch as diffMatchPatch } from 'diff-match-patch';
import MimeTypes from 'mime-types';
import { unionBy } from 'lodash';
import { Image } from 'react-native';
import VersionNumber from 'react-native-version-number';
import getSlug from 'speakingurl';
Expand Down Expand Up @@ -112,37 +113,31 @@ export const makeOptions = (postObj) => {
permlink: postObj.permlink,
max_accepted_payout: '1000000.000 HBD',
percent_hbd: 10000,
extensions: [],
extensions: [] as any,
};

switch (postObj.operationType) {
case 'sp':
a.max_accepted_payout = '1000000.000 HBD';
a.percent_hbd = 0;
if (postObj.beneficiaries && postObj.beneficiaries.length > 0) {
postObj.beneficiaries.sort((a, b) => a.account.localeCompare(b.account));
a.extensions = [[0, { beneficiaries: postObj.beneficiaries }]];
}
break;

case 'dp':
a.max_accepted_payout = '0.000 HBD';
a.percent_hbd = 10000;
if (postObj.beneficiaries && postObj.beneficiaries.length > 0) {
postObj.beneficiaries.sort((a, b) => a.account.localeCompare(b.account));
a.extensions = [[0, { beneficiaries: postObj.beneficiaries }]];
}
break;

default:
a.max_accepted_payout = '1000000.000 HBD';
a.percent_hbd = 10000;
if (postObj.beneficiaries && postObj.beneficiaries.length > 0) {
postObj.beneficiaries.sort((a, b) => a.account.localeCompare(b.account));
a.extensions = [[0, { beneficiaries: postObj.beneficiaries }]];
}
break;
}

if (postObj.beneficiaries && postObj.beneficiaries.length > 0) {
postObj.beneficiaries.sort((a, b) => a.account.localeCompare(b.account));
a.extensions = [[0, { beneficiaries: unionBy(postObj.beneficiaries, 'account') }]];
}

return a;
};

Expand Down

0 comments on commit b64c750

Please sign in to comment.