tornado-initiation-ui/store/airdrop/actions.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-11-20 17:11:39 +01:00
import { localStorage } from '@/utillites'
2020-11-21 11:46:25 +01:00
import { SET_AIRDROP, SET_NOTIFICATION } from './constant'
2020-11-20 17:11:39 +01:00
export default {
setAirdropAddresses({ getters, commit }) {
const savedActions = localStorage.getItem('actions')
if (savedActions) {
commit(SET_AIRDROP, savedActions)
return
}
const actions = getters.selectAirdropData
localStorage.setItem('actions', actions)
commit(SET_AIRDROP, actions)
},
2020-11-21 11:46:25 +01:00
checkAddress({ rootGetters, commit, dispatch, state }) {
const address = rootGetters['provider/getAccount']
const callback = () => {
window.scrollTo({
behavior: 'smooth',
left: 0,
top: document.getElementById('current').getBoundingClientRect().top,
})
}
state.airdrops.forEach((item, index) => {
item.forEach((i) => {
if (i.address === address) {
commit(SET_NOTIFICATION, index)
dispatch(
'notice/addNotice',
{
notice: {
type: 'success',
title: 'You have airdrop',
callback,
},
},
{ root: true }
)
}
})
})
},
2020-11-20 17:11:39 +01:00
}