|
10 | 10 | <img :src="iconTip"> |
11 | 11 | <template v-if="!userAddress"> |
12 | 12 | <AeAmountFiat |
13 | | - v-if="!isTokenAndZeroAeTip" |
14 | | - :amount="tip ? tipUrlStats.amount_ae || tip.total_amount_ae : '0'" |
| 13 | + v-if="!tipUrlStats.tokenTotalAmount.length || +tipUrlStats.totalAmountAe !== 0" |
| 14 | + :amount="tipUrlStats.totalAmountAe" |
15 | 15 | /> |
16 | 16 | <AeAmountFiat |
17 | | - v-for="tokenTip in tipUrlStats.token_total_amount || tip.token_total_amount" |
| 17 | + v-for="tokenTip in tipUrlStats.tokenTotalAmount" |
18 | 18 | :key="tokenTip.token" |
19 | 19 | :amount="tokenTip.amount" |
20 | 20 | :token="tokenTip.token" |
|
61 | 61 |
|
62 | 62 | <script> |
63 | 63 | import { mapState, mapGetters } from 'vuex'; |
64 | | -import BigNumber from 'bignumber.js'; |
65 | 64 | import iconTip from '../assets/iconTip.svg'; |
66 | 65 | import iconTipUser from '../assets/iconTipUser.svg'; |
67 | 66 | import iconTipped from '../assets/iconTipped.svg'; |
@@ -102,19 +101,13 @@ export default { |
102 | 101 | ...mapState('backend', { |
103 | 102 | tipUrlStats({ stats }) { |
104 | 103 | const urlStats = stats && stats.by_url.find(({ url }) => url === this.tipUrl); |
105 | | - if (!urlStats) return {}; |
106 | 104 | return { |
107 | | - isTipped: urlStats.senders.includes(this.address), |
108 | | - amount_ae: urlStats.total_amount_ae, |
109 | | - token_total_amount: urlStats.token_total_amount, |
| 105 | + isTipped: urlStats ? urlStats.senders.includes(this.address) : false, |
| 106 | + totalAmountAe: urlStats ? urlStats.total_amount_ae : '0', |
| 107 | + tokenTotalAmount: urlStats ? urlStats.token_total_amount : [], |
110 | 108 | }; |
111 | 109 | }, |
112 | 110 | }), |
113 | | - isTokenAndZeroAeTip() { |
114 | | - return new BigNumber(this.tipUrlStats.amount_ae || '0').isZero() |
115 | | - && new BigNumber(this.tip.total_amount_ae).isZero() |
116 | | - && !!this.tip.token; |
117 | | - }, |
118 | 111 | isTokenTipable() { |
119 | 112 | return this.tip.id.split('_')[1] === 'v2'; |
120 | 113 | }, |
@@ -154,11 +147,8 @@ export default { |
154 | 147 | const amount = shiftDecimalPlaces(this.inputValue, |
155 | 148 | this.inputToken !== 'native' ? this.tokenInfo[this.inputToken].decimals : 18).toFixed(); |
156 | 149 |
|
157 | | - if (this.tipUrl !== this.tip.url) { |
158 | | - await tip(this.tipUrl, this.message, amount, this.inputToken); |
159 | | - } else { |
160 | | - await retip(this.tip.contractId, this.tip.id, amount, this.inputToken); |
161 | | - } |
| 150 | + if (!this.tip) await tip(this.tipUrl, this.message, amount, this.inputToken); |
| 151 | + else await retip(this.tip.contractId, this.tip.id, amount, this.inputToken); |
162 | 152 |
|
163 | 153 | if (!this.userAddress) { |
164 | 154 | await Backend.cacheInvalidateTips(); |
|
0 commit comments