Skip to content

Commit

Permalink
Cleanup: remove paddingForSwapList/changePaddingValue/paddingContaine…
Browse files Browse the repository at this point in the history
…rValue (#3511)
  • Loading branch information
iower committed Nov 28, 2020
1 parent 1aa3733 commit 24849e1
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 133 deletions.
19 changes: 0 additions & 19 deletions src/front/shared/helpers/paddingForSwapList.ts

This file was deleted.

23 changes: 3 additions & 20 deletions src/front/shared/pages/Swap/UTXOSwap/EthToUTXO.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import FeeControler from '../FeeControler/FeeControler'
import SwapProgress from './SwapProgress/SwapProgress'
import SwapList from './SwapList/SwapList'
import DepositWindow from './DepositWindow/DepositWindow'
import paddingForSwapList from 'shared/helpers/paddingForSwapList'


@CSSModules(styles)
export default class EthToUTXO extends Component<any, any> {
Expand Down Expand Up @@ -42,7 +42,6 @@ export default class EthToUTXO extends Component<any, any> {
enoughBalance,
signed: false,
depositWindow,
paddingContainerValue: 0,
enabledButton: false,
isAddressCopied: false,
flow: this.swap.flow.state,
Expand All @@ -58,7 +57,6 @@ export default class EthToUTXO extends Component<any, any> {

componentDidMount() {
const { swap, flow: { isSignFetching, isMeSigned, step } } = this.state
this.changePaddingValue()
window.addEventListener('resize', this.updateWindowDimensions)
this.updateWindowDimensions()
this.signTimer = setInterval(() => {
Expand All @@ -83,23 +81,10 @@ export default class EthToUTXO extends Component<any, any> {
window.removeEventListener('resize', this.updateWindowDimensions)
}

componentDidUpdate(prevProps, prevState) {
if (prevState.flow !== this.state.flow) {
this.changePaddingValue()
}
}

updateWindowDimensions = () => {
this.setState({ windowWidth: window.innerWidth })
}

changePaddingValue = () => {
const { flow: { step } } = this.state
this.setState(() => ({
paddingContainerValue: paddingForSwapList({ step }),
}))
}

confirmScriptChecked = () => {
const {
verifyScriptFunc,
Expand Down Expand Up @@ -134,8 +119,6 @@ export default class EthToUTXO extends Component<any, any> {
flow: values,
})

this.changePaddingValue()

}

signSwap = () => {
Expand Down Expand Up @@ -165,12 +148,12 @@ export default class EthToUTXO extends Component<any, any> {
wallets,
} = this.props

const { currencyAddress, flow, isShowingScript, swap, currencyData, signed, paddingContainerValue, buyCurrency, sellCurrency, windowWidth } = this.state
const { currencyAddress, flow, isShowingScript, swap, currencyData, signed, buyCurrency, sellCurrency, windowWidth } = this.state
const stepse = flow.step

return (
<div>
<div styleName="swapContainer" style={(isMobile && (windowWidth < 569)) ? { paddingTop: paddingContainerValue } : { paddingTop: 0 }}>
<div styleName="swapContainer" style={(isMobile && (windowWidth < 569)) ? { paddingTop: 120 } : { paddingTop: 0 }}>
<div>
<div styleName="swapInfo">
{this.swap.id &&
Expand Down
18 changes: 0 additions & 18 deletions src/front/shared/pages/Swap/UTXOSwap/EthTokenToUTXO.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import SwapList from './SwapList/SwapList'
import FeeControler from '../FeeControler/FeeControler'
import FailControler from '../FailControler/FailControler'
import DepositWindow from './DepositWindow/DepositWindow'
import paddingForSwapList from 'shared/helpers/paddingForSwapList'


@CSSModules(styles)
Expand Down Expand Up @@ -39,7 +38,6 @@ export default class EthTokenToUTXO extends Component<any, any> {
currencyData,
tokenItems,
signed: false,
paddingContainerValue: 0,
enabledButton: false,
isAddressCopied: false,
flow: this.swap.flow.state,
Expand All @@ -66,8 +64,6 @@ export default class EthTokenToUTXO extends Component<any, any> {
},
} = this.state

this.changePaddingValue()

this.signTimer = setInterval(() => {
if (!this.state.flow.isMeSigned) {
this.signSwap()
Expand All @@ -87,23 +83,10 @@ export default class EthTokenToUTXO extends Component<any, any> {
this.requestMaxAllowance()
}

componentDidUpdate(prevProps, prevState) {
if (prevState.flow !== this.state.flow) {
this.changePaddingValue()
}
}

confirmScriptChecked = () => {
this.swap.flow[this._fields.verifyScriptFunc]()
}

changePaddingValue = () => {
const { flow: { step } } = this.state
this.setState(() => ({
paddingContainerValue: paddingForSwapList({ step }),
}))
}

handleFlowStateUpdate = (values) => {

const stepNumbers = {
Expand Down Expand Up @@ -168,7 +151,6 @@ export default class EthTokenToUTXO extends Component<any, any> {
currencyData,
tokenItems,
signed,
paddingContainerValue,
swap,
} = this.state

Expand Down
22 changes: 2 additions & 20 deletions src/front/shared/pages/Swap/UTXOSwap/UTXOToEth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import SwapProgress from './SwapProgress/SwapProgress'
import DepositWindow from './DepositWindow/DepositWindow'
import FeeControler from '../FeeControler/FeeControler'
import SwapList from './SwapList/SwapList'
import paddingForSwapList from 'shared/helpers/paddingForSwapList'


@CSSModules(styles)
Expand All @@ -34,7 +33,6 @@ export default class UTXOToEth extends Component<any, any> {
currencyData,
enabledButton: false,
flow: this.swap.flow.state,
paddingContainerValue: 60,
currencyAddress: currencyData.address,
secret: crypto.randomBytes(32).toString('hex'),
}
Expand All @@ -48,7 +46,6 @@ export default class UTXOToEth extends Component<any, any> {
const { flow: { isSignFetching, isMeSigned, step, isParticipantSigned } } = this.state
window.addEventListener('resize', this.updateWindowDimensions)
this.updateWindowDimensions()
this.changePaddingValue()
this.ParticipantTimer = setInterval(() => {
if (this.state.flow.isParticipantSigned && this.state.destinationBuyAddress) {
this.submitSecret()
Expand All @@ -75,19 +72,6 @@ export default class UTXOToEth extends Component<any, any> {
this.swap.flow.submitSecret(secret)
}

componentDidUpdate(prevProps, prevState) {
if (prevState.flow !== this.state.flow) {
this.changePaddingValue()
}
}

changePaddingValue = () => {
const { flow: { step } } = this.state
this.setState(() => ({
paddingContainerValue: paddingForSwapList({ step }),
}))
}

handleFlowStateUpdate = (values) => {
/** todo - not used - remove **/
const stepNumbers = {
Expand All @@ -106,8 +90,6 @@ export default class UTXOToEth extends Component<any, any> {
this.setState({
flow: values,
})

this.changePaddingValue()
}

updateBalance = () => {
Expand Down Expand Up @@ -147,14 +129,14 @@ export default class UTXOToEth extends Component<any, any> {
wallets,
} = this.props

const { flow, isShowingGhostScript, currencyData, paddingContainerValue, windowWidth } = this.state
const { flow, isShowingGhostScript, currencyData, windowWidth } = this.state

return (
<div>
<div
styleName="swapContainer"
style={(isMobile && (windowWidth < 569))
? { paddingTop: paddingContainerValue }
? { paddingTop: 120 }
: { paddingTop: 0 }
}>
<div>
Expand Down
16 changes: 0 additions & 16 deletions src/front/shared/pages/Swap/UTXOSwap/UTXOToEthToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import DepositWindow from './DepositWindow/DepositWindow'
import SwapProgress from './SwapProgress/SwapProgress'
import SwapList from './SwapList/SwapList'
import FeeControler from '../FeeControler/FeeControler'
import paddingForSwapList from 'shared/helpers/paddingForSwapList'


@CSSModules(styles)
Expand All @@ -37,7 +36,6 @@ export default class UTXOToEthToken extends Component<any, any> {
enabledButton: false,
isAddressCopied: false,
flow: this.swap.flow.state,
paddingContainerValue: 0,
destinationAddressTimer: true,
isShowingScript: false,
currencyAddress: currencyData.address,
Expand All @@ -59,7 +57,6 @@ export default class UTXOToEthToken extends Component<any, any> {

componentDidMount() {
const { swap, flow: { step, isParticipantSigned } } = this.state
this.changePaddingValue()

this.ParticipantTimer = setInterval(() => {
if (this.state.flow.isParticipantSigned && this.state.destinationBuyAddress) {
Expand All @@ -71,23 +68,11 @@ export default class UTXOToEthToken extends Component<any, any> {
}, 3000)
}

componentDidUpdate(prevProps, prevState) {
if (prevState.flow !== this.state.flow) {
this.changePaddingValue()
}
}

submitSecret = () => {
const { secret } = this.state
this.swap.flow.submitSecret(secret)
}

changePaddingValue = () => {
const { flow: { step } } = this.state
this.setState(() => ({
paddingContainerValue: paddingForSwapList({ step }),
}))
}

handleFlowStateUpdate = (values) => {

Expand Down Expand Up @@ -166,7 +151,6 @@ export default class UTXOToEthToken extends Component<any, any> {
flow,
secret,
ethAddress,
paddingContainerValue,
isShowingScript,
} = this.state

Expand Down
23 changes: 3 additions & 20 deletions src/front/shared/pages/Swap/_BtcToGhost.tsx_
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import FeeControler from './FeeControler/FeeControler'
import SwapProgress from './SwapProgress/SwapProgress'
import SwapList from './SwapList/SwapList'
import DepositWindow from './DepositWindow/DepositWindow'
import paddingForSwapList from 'shared/helpers/paddingForSwapList'


@CSSModules(styles)
export default class BtcToGhost extends Component<any, any> {
Expand All @@ -37,7 +37,6 @@ export default class BtcToGhost extends Component<any, any> {
enoughBalance,
signed: false,
depositWindow,
paddingContainerValue: 0,
enabledButton: false,
isAddressCopied: false,
flow: this.swap.flow.state,
Expand All @@ -57,7 +56,6 @@ export default class BtcToGhost extends Component<any, any> {

componentDidMount() {
const { swap, flow: { isSignFetching, isMeSigned, step } } = this.state
this.changePaddingValue()
window.addEventListener('resize', this.updateWindowDimensions)
this.updateWindowDimensions()
this.signTimer = setInterval(() => {
Expand All @@ -82,23 +80,10 @@ export default class BtcToGhost extends Component<any, any> {
window.removeEventListener('resize', this.updateWindowDimensions)
}

componentDidUpdate(prevProps, prevState) {
if (prevState.flow !== this.state.flow) {
this.changePaddingValue()
}
}

updateWindowDimensions = () => {
this.setState({ windowWidth: window.innerWidth })
}

changePaddingValue = () => {
const { flow: { step } } = this.state
this.setState(() => ({
paddingContainerValue: paddingForSwapList({ step }),
}))
}

confirmGhostScriptChecked = () => {
this.swap.flow.verifyGhostScript()
}
Expand All @@ -123,8 +108,6 @@ export default class BtcToGhost extends Component<any, any> {
flow: values,
})

this.changePaddingValue()

}

signSwap = () => {
Expand Down Expand Up @@ -154,12 +137,12 @@ export default class BtcToGhost extends Component<any, any> {
wallets,
} = this.props

const { currencyAddress, flow, isShowingBitcoinScript, swap, currencyData, signed, paddingContainerValue, buyCurrency, sellCurrency, windowWidth } = this.state
const { currencyAddress, flow, isShowingBitcoinScript, swap, currencyData, signed, buyCurrency, sellCurrency, windowWidth } = this.state
const stepse = flow.step

return (
<div>
<div styleName="swapContainer" style={(isMobile && (windowWidth < 569)) ? { paddingTop: paddingContainerValue } : { paddingTop: 0 }}>
<div styleName="swapContainer" style={(isMobile && (windowWidth < 569)) ? { paddingTop: 120 } : { paddingTop: 0 }}>
<div>
<div styleName="swapInfo">
{this.swap.id &&
Expand Down
Loading

0 comments on commit 24849e1

Please sign in to comment.