Skip to content

Commit

Permalink
Fix sponsors
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed Nov 11, 2023
1 parent 2bcee4f commit ece440c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
18 changes: 12 additions & 6 deletions app/components/modules/PostForm/PostForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ class PostForm extends React.Component {
data,
editMode,
visibleType,
() => {
(payload) => {
try {
if (editMode) {
sessionStorage.removeItem(EDIT_KEY);
Expand All @@ -667,11 +667,15 @@ class PostForm extends React.Component {
} catch (err) {}

if (!this._unmount) {
this.setState({
isPosting: false,
});
setTimeout(() => {
if (!this._unmount) {
this.setState({
isPosting: false,
})
}
}, 1000)

this.props.onSuccess();
this.props.onSuccess(payload, editMode, visibleType)
}

if (!editMode) {
Expand Down Expand Up @@ -835,7 +839,9 @@ export default connect(
confirm,
hideErrors: true,
errorCallback: onError,
successCallback: onSuccess,
successCallback: () => {
onSuccess(payload)
},
})
);
},
Expand Down
10 changes: 6 additions & 4 deletions app/components/modules/SponsorSubscription.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class SponsorSubscription extends React.Component {
const { username } = this.props
this.setSubmitting(true)
if (values.author) {
await this.props.updatePso(username, values.oid, values.cost, () => {
await this.props.updatePso(username, values.oid, values.cost, values.subscribers, () => {
this.setState({
saved: true,
})
Expand Down Expand Up @@ -175,7 +175,7 @@ class SponsorSubscription extends React.Component {
onSubmit={this._onSubmit}
>
{({
handleSubmit, isValid, values, setFieldValue, handleChange,
handleSubmit, isValid, values, dirty, setFieldValue, handleChange,
}) => {
const { symbol } = values.cost.asset
return (
Expand All @@ -196,7 +196,7 @@ class SponsorSubscription extends React.Component {
</div>
<div className='row' style={{ marginTop: '0.5rem' }}>
{pso.author ? <div className='column small-6'>
<button type='submit' disabled={!isValid || submitting} className='button'>
<button type='submit' disabled={!isValid || !dirty || submitting} className='button'>
{tt('g.save')}
</button>
<button type='button' disabled={submitting} className='button hollow alert' onClick={this.deletePso}>
Expand Down Expand Up @@ -265,7 +265,7 @@ export default connect(
})
)
},
updatePso: async (author, oid, cost, successCallback, errorCallback) => {
updatePso: async (author, oid, cost, subscribers, successCallback, errorCallback) => {
const operation = {
author,
oid,
Expand All @@ -275,9 +275,11 @@ export default connect(
executions: 4294967295,
extensions: []
}
const confirm = tt('sponsors_jsx.are_you_sure_update')
dispatch(
transaction.actions.broadcastOperation({
type: 'paid_subscription_update',
confirm,
operation,
successCallback,
errorCallback
Expand Down
14 changes: 11 additions & 3 deletions app/components/pages/SubmitPost.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from 'react';
import { browserHistory } from 'react-router';
import PostFormLoader from 'app/components/modules/PostForm/loader';

import ReplyEditor from 'app/components/elements/ReplyEditor';
import PostFormLoader from 'app/components/modules/PostForm/loader'
import { VISIBLE_TYPES } from 'app/components/modules/PostForm/PostForm'

class SubmitPost extends React.PureComponent {
constructor(props) {
Expand Down Expand Up @@ -35,8 +37,14 @@ class SubmitPost extends React.PureComponent {
}
}

_onSuccess = () => {
browserHistory.push('/created');
_onSuccess = (payload, editMode, visibleType) => {
if (visibleType === VISIBLE_TYPES.ONLY_SPONSORS) {
setTimeout(() => {
browserHistory.push('/@' + payload.author)
}, 1000)
return
}
browserHistory.push('/created')
};
}

Expand Down
1 change: 1 addition & 0 deletions app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,7 @@
"fill_cost": "Please fill the amount.",
"are_you_sure": "Are you sure you want to remove subscription?",
"are_you_sure_COUNT": "You have %(COUNT)s sponsor(-s). All of them will be automatically unsubscribed. Are you sure?",
"are_you_sure_update": "Sponsorship will be stopped for all sponsors, and will be continued only after payment with new price. Are you sure?",
"your_sponsors": "Sponsors ",
"sponsored_authors": "Sponsored authors",
"created": "Created"
Expand Down
1 change: 1 addition & 0 deletions app/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@
"fill_cost": "Укажите сумму.",
"are_you_sure": "Вы уверены, что хотите удалить подписку?",
"are_you_sure_COUNT": "У вас есть %(COUNT)s спонсор(-ов). Все они будут автоматически отписаны от вас. Вы уверены?",
"are_you_sure_update": "Подписка у спонсоров будет приостановлена и только после повторной оплаты по новой цене будет продолжена, вы уверены?",
"your_sponsors": "Спонсоры ",
"sponsored_authors": "Спонсируемые авторы",
"created": "Создано"
Expand Down

0 comments on commit ece440c

Please sign in to comment.