Skip to content

Commit

Permalink
Auto increase bid to minimum (#3209)
Browse files Browse the repository at this point in the history
* Auto increase bid to MINIMUM_PUBLISH_BID on playlist publish load

* Auto increase bid to MINIMUM_PUBLISH_BID on upload edit load

---------

Co-authored-by: miko <[email protected]>
  • Loading branch information
keikari and miko authored Jan 13, 2025
1 parent 84321f2 commit c4af5ba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ui/component/publish/shared/publishBid/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ function PublishBid(props: Props) {
const [bidError, setBidError] = useState(undefined);
const previousBidAmount = myClaimForUri && Number(myClaimForUri.amount);

useEffect(() => {
if (bid < MINIMUM_PUBLISH_BID) {
updatePublishForm({ bid: parseFloat(MINIMUM_PUBLISH_BID) });
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
const totalAvailableBidAmount = previousBidAmount ? previousBidAmount + balance : balance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import classnames from 'classnames';

import SUPPORTED_LANGUAGES from 'constants/supported_languages';
import * as PUBLISH from 'constants/publish';
import { MINIMUM_PUBLISH_BID } from 'constants/claim';

import { FormField } from 'component/common/form';
import { handleBidChange, handleLanguageChange } from 'util/publish';
Expand Down Expand Up @@ -43,9 +44,17 @@ function CollectionPublishAdditionalOptions(props: Props) {
setHideSection(!hideSection);
}

const isFirstRun = React.useRef(true);
React.useEffect(() => {
let bid = formParams.bid;
if (isFirstRun.current) {
isFirstRun.current = false;
if (bid < MINIMUM_PUBLISH_BID) {
bid = MINIMUM_PUBLISH_BID;
}
}
handleBidChange(
parseFloat(formParams.bid),
parseFloat(bid),
amount,
balance,
(value) => {
Expand Down

0 comments on commit c4af5ba

Please sign in to comment.