Skip to content

Commit

Permalink
Display activation code when mining
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenaio committed Jul 3, 2019
1 parent 660c858 commit fd385b4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
11 changes: 10 additions & 1 deletion main/stores/invites.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const adapter = new FileSync(dbPath('invites.json'))
const db = low(adapter)

// Set some defaults (required if your JSON file is empty)
db.defaults({invites: [], activationTx: ''}).write()
db.defaults({invites: [], activationTx: '', activationCode: ''}).write()

function getInvites() {
return db.get('invites')
Expand Down Expand Up @@ -46,4 +46,13 @@ module.exports = {
clearActivationTx() {
db.set('activationTx', '').write()
},
getActivationCode() {
return db.get('activationCode').value()
},
setActivationCode(code) {
db.set('activationCode', code).write()
},
clearActivationCode() {
db.set('activationCode', '').write()
},
}
3 changes: 2 additions & 1 deletion renderer/screens/contacts/components/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ function Sidebar({onSelectContact, onSelectInvite}) {
style={{
...border('right', '1px', 'solid', theme.colors.gray2),
width: rem(240),
minHeight: '100vh',
height: '100vh',
overflowY: 'auto',
}}
>
<Search onChange={e => setTerm(e.target.value)} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function ActivateInviteForm() {

const {addError} = useNotificationDispatch()

const {activationTx} = useInviteState()
const {activationTx, activationCode} = useInviteState()
const {activateInvite} = useInviteDispatch()

const {canActivateInvite, state: status} = useIdentityState()
Expand All @@ -42,6 +42,7 @@ function ActivateInviteForm() {
...margin(0, theme.spacings.normal, 0, 0),
width: rem(400),
}}
defaultValue={activationCode}
/>
<Button
disabled={mining}
Expand Down
1 change: 1 addition & 0 deletions renderer/shared/components/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function Notification({title, body, type = NotificationType.Info}) {
bg={theme.colors.white}
px={rem(16)}
py={rem(12)}
my={rem(theme.spacings.small8)}
css={{
borderRadius: rem(8),
boxShadow: `0 3px 12px 0 rgba(83, 86, 92, 0.1), 0 2px 3px 0 rgba(83, 86, 92, 0.2)`,
Expand Down
3 changes: 2 additions & 1 deletion renderer/shared/components/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function Sidebar() {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100vh;
padding: 0 ${rem(16)};
width: ${rem(250)};
position: relative;
Expand Down Expand Up @@ -309,7 +310,7 @@ function CurrentTask({period, identity}) {
}

if (period === EpochPeriod.FlipLottery) {
return 'Flips lottery'
return 'Flip lottery'
}

if (period === EpochPeriod.AfterLongSession) {
Expand Down
15 changes: 12 additions & 3 deletions renderer/shared/providers/invite-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const InviteDispatchContext = React.createContext()
function InviteProvider({children}) {
const [invites, setInvites] = React.useState([])
const [activationTx, setActivationTx] = React.useState()
const [activationCode, setActivationCode] = React.useState()

const {address} = useIdentityState()
const {addNotification} = useNotificationDispatch()
Expand Down Expand Up @@ -42,8 +43,8 @@ function InviteProvider({children}) {
const savedInvites = db.getInvites()
fetchData()

const savedActivationTx = db.getActivationTx()
setActivationTx(savedActivationTx)
setActivationTx(db.getActivationTx())
setActivationCode(db.getActivationCode())

return () => {
ignore = true
Expand Down Expand Up @@ -111,6 +112,10 @@ function InviteProvider({children}) {
if (result) {
setActivationTx(result)
db.setActivationTx(result)
if (code) {
setActivationCode(code)
db.setActivationCode(code)
}
} else {
throw new Error(error.message)
}
Expand All @@ -119,10 +124,14 @@ function InviteProvider({children}) {
const resetActivation = () => {
setActivationTx('')
db.clearActivationTx()
setActivationCode('')
db.clearActivationCode()
}

return (
<InviteStateContext.Provider value={{invites, activationTx}}>
<InviteStateContext.Provider
value={{invites, activationTx, activationCode}}
>
<InviteDispatchContext.Provider
value={{addInvite, activateInvite, resetActivation}}
>
Expand Down

0 comments on commit fd385b4

Please sign in to comment.