Gradually replace default tips with user-defined ones on long press (up to 7) (#2069)
* commented the lines to make sure dupes are also checked on subdomains * chore: fix lint issues * add more than 3 custom tips, up to 7 total * fix merge issue * shorten logic * don't check length for slice without need --------- Co-authored-by: 김현희 <pygmal@gimhyeonhuiui-MacBookAir.local> Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com> Co-authored-by: k00b <k00b@stacker.news>
This commit is contained in:
parent
1835a8f255
commit
af096a08a0
@ -18,7 +18,10 @@ import { useSendWallets } from '@/wallets/index'
|
||||
const defaultTips = [100, 1000, 10_000, 100_000]
|
||||
|
||||
const Tips = ({ setOValue }) => {
|
||||
const tips = [...getCustomTips(), ...defaultTips].sort((a, b) => a - b)
|
||||
const customTips = getCustomTips()
|
||||
const defaultNoCustom = defaultTips.filter(d => !customTips.includes(d))
|
||||
const tips = [...customTips, ...defaultNoCustom].slice(0, 7).sort((a, b) => a - b)
|
||||
|
||||
return tips.map((num, i) =>
|
||||
<Button
|
||||
size='sm'
|
||||
@ -37,11 +40,7 @@ const Tips = ({ setOValue }) => {
|
||||
const getCustomTips = () => JSON.parse(window.localStorage.getItem('custom-tips')) || []
|
||||
|
||||
const addCustomTip = (amount) => {
|
||||
if (defaultTips.includes(amount)) return
|
||||
let customTips = Array.from(new Set([amount, ...getCustomTips()]))
|
||||
if (customTips.length > 3) {
|
||||
customTips = customTips.slice(0, 3)
|
||||
}
|
||||
const customTips = Array.from(new Set([amount, ...getCustomTips()])).slice(0, 7)
|
||||
window.localStorage.setItem('custom-tips', JSON.stringify(customTips))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user