Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nt/beneficiary extraction #2914

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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