From a733cf77c93db1cd38943383cf8e6cf132198d4d Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 27 Aug 2019 11:03:38 +1000 Subject: [PATCH 01/10] events --- server/src/events.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/events.rs b/server/src/events.rs index eb5e12d5..f37b97bd 100644 --- a/server/src/events.rs +++ b/server/src/events.rs @@ -132,7 +132,7 @@ impl Events { match self.clients.get_mut(&id) { Some(client) => { client.subs.insert(obj); - info!("client subscriptions={:?}", client.subs.len()); + info!("client={:?} subscriptions={:?}", id, client.subs.len()); Ok(()) }, None => return Err(format_err!("unknown client {:?}", id)) From 338a7e082c18d80a3b0b3a8e0ad17521730fdca4 Mon Sep 17 00:00:00 2001 From: Mashy Date: Tue, 27 Aug 2019 16:30:59 +1000 Subject: [PATCH 02/10] construct page selection --- client/assets/styles/controls.less | 10 ++++++++++ client/src/actions.jsx | 1 + client/src/components/team.ctrl.jsx | 25 ++++++++++++++++++++++++- client/src/components/team.jsx | 8 ++++++-- client/src/reducers.jsx | 1 + 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/client/assets/styles/controls.less b/client/assets/styles/controls.less index 09713fc6..d036debc 100644 --- a/client/assets/styles/controls.less +++ b/client/assets/styles/controls.less @@ -76,3 +76,13 @@ aside { transition-duration: 0.25s; transition-timing-function: ease; } + +.team-page-ctrl { + display: flex; + height: 3em; + align-items: center; +} + +.team-page-ctrl h2 { + padding: 0 0.75em 0 0.75em; +} diff --git a/client/src/actions.jsx b/client/src/actions.jsx index 1fde403a..5a829cb7 100644 --- a/client/src/actions.jsx +++ b/client/src/actions.jsx @@ -33,6 +33,7 @@ export const setSkip = value => ({ type: 'SET_SKIP', value }); export const setShop = value => ({ type: 'SET_SHOP', value }); export const setTeam = value => ({ type: 'SET_TEAM', value: Array.from(value) }); +export const setTeamPage = value => ({ type: 'SET_TEAM_PAGE', value }); export const setTeamSelect = value => ({ type: 'SET_TEAM_SELECT', value: Array.from(value) }); export const setVboxHighlight = value => ({ type: 'SET_VBOX_HIGHLIGHT', value }); diff --git a/client/src/components/team.ctrl.jsx b/client/src/components/team.ctrl.jsx index fb45db9e..ba13edf1 100644 --- a/client/src/components/team.ctrl.jsx +++ b/client/src/components/team.ctrl.jsx @@ -6,6 +6,8 @@ const actions = require('./../actions'); const addState = connect( function receiveState(state) { const { + constructs, + teamPage, teamSelect, ws, } = state; @@ -15,18 +17,34 @@ const addState = connect( } return { + constructLength: constructs.length, sendAccountSetTeam, + teamPage, teamSelect, }; }, + + function receiveDispatch(dispatch) { + function setTeamPage(value) { + return dispatch(actions.setTeamPage(value)); + } + return { + setTeamPage, + }; + } ); function TeamCtrl(args) { const { - teamSelect, + constructLength, sendAccountSetTeam, + setTeamPage, + teamPage, + teamSelect, } = args; + const disableDecrement = teamPage === 0; + const disableIncrement = (teamPage + 1) * 6 >= constructLength; return ( ); } diff --git a/client/src/components/team.jsx b/client/src/components/team.jsx index af48f6ca..9fbb3cff 100644 --- a/client/src/components/team.jsx +++ b/client/src/components/team.jsx @@ -7,7 +7,7 @@ const { ConstructAvatar } = require('./construct'); const addState = connect( function receiveState(state) { - const { ws, constructs, teamSelect } = state; + const { ws, constructs, teamPage, teamSelect } = state; function sendConstructSpawn(name) { return ws.sendMtxConstructSpawn(name); @@ -15,6 +15,7 @@ const addState = connect( return { constructs, + teamPage, teamSelect, }; }, @@ -32,6 +33,7 @@ const addState = connect( function Team(args) { const { constructs, + teamPage, teamSelect, setTeam, } = args; @@ -54,8 +56,10 @@ function Team(args) { teamSelect[insert] = id; return setTeam(teamSelect); } + console.log(constructs.length); + const dispConstructs = constructs.length >= ((teamPage + 1) * 6) ? constructs.slice(teamPage * 6, (teamPage + 1) * 6) : constructs.slice(teamPage * 6, constructs.length); - const constructPanels = constructs.map(construct => { + const constructPanels = dispConstructs.map(construct => { const colour = teamSelect.indexOf(construct.id); const selected = colour > -1; diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index 8c9beb5b..73c8e16c 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -45,6 +45,7 @@ module.exports = { shop: createReducer(false, 'SET_SHOP'), team: createReducer([], 'SET_TEAM'), + teamPage: createReducer(0, 'SET_TEAM_PAGE'), teamSelect: createReducer([null, null, null], 'SET_TEAM_SELECT'), vboxHighlight: createReducer([], 'SET_VBOX_HIGHLIGHT'), From 61528f7739190b0552ff640fe3abe1445c81cdea Mon Sep 17 00:00:00 2001 From: Mashy Date: Tue, 27 Aug 2019 16:35:48 +1000 Subject: [PATCH 03/10] ternary format --- client/src/components/team.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/components/team.jsx b/client/src/components/team.jsx index 9fbb3cff..cb88b526 100644 --- a/client/src/components/team.jsx +++ b/client/src/components/team.jsx @@ -57,7 +57,9 @@ function Team(args) { return setTeam(teamSelect); } console.log(constructs.length); - const dispConstructs = constructs.length >= ((teamPage + 1) * 6) ? constructs.slice(teamPage * 6, (teamPage + 1) * 6) : constructs.slice(teamPage * 6, constructs.length); + const dispConstructs = constructs.length >= ((teamPage + 1) * 6) + ? constructs.slice(teamPage * 6, (teamPage + 1) * 6) + : constructs.slice(teamPage * 6, constructs.length); const constructPanels = dispConstructs.map(construct => { const colour = teamSelect.indexOf(construct.id); From d726aa8d33da60b25447c686f48ac89f21f2cfa0 Mon Sep 17 00:00:00 2001 From: ntr Date: Wed, 28 Aug 2019 18:57:23 +1000 Subject: [PATCH 04/10] stripe sub cancellations --- WORKLOG.md | 11 +-- client/assets/styles/account.less | 12 +++ client/assets/styles/styles.less | 4 + client/src/app.jsx | 2 +- client/src/components/account.management.jsx | 84 ++++++++++++++------ client/src/components/stripe.buttons.jsx | 2 +- client/src/events.jsx | 7 ++ client/src/socket.jsx | 11 +++ etc/mnml/{gs.SAMPLE.conf => gs.conf} | 2 + server/Cargo.toml | 3 +- server/src/main.rs | 4 +- server/src/payments.rs | 50 +++++++++++- server/src/rpc.rs | 20 ++++- 13 files changed, 173 insertions(+), 39 deletions(-) rename etc/mnml/{gs.SAMPLE.conf => gs.conf} (83%) diff --git a/WORKLOG.md b/WORKLOG.md index bb9934a4..7860dae3 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -3,8 +3,7 @@ *PRODUCTION* * ACP * essential - * error log - * account lookup w/ pw reset + * stripe verify * treats * constructs jiggle when clicked @@ -13,12 +12,9 @@ * bot game grind * serde serialize privatise -* stripe prod * mobile styles * change score to enum * pct based translates for combat animation -* account page -* graphs n shit * acp init * DO postgres * make our own toasts / msg pane @@ -28,6 +24,8 @@ * clear skill (if currently targetted) * increase power to speed up early rounds +* only login / logout / register http + ## SOON *SERVER* * modules @@ -38,12 +36,15 @@ * empower on ko * rework vecs into sets +* remove names so games/instances are copy *$$$* * chatwheel * eth adapter * illusions * vaporwave +* crop circles +* insects * sacred geometry * skulls / day of the dead * Aztec diff --git a/client/assets/styles/account.less b/client/assets/styles/account.less index a73faaae..cd4730ca 100644 --- a/client/assets/styles/account.less +++ b/client/assets/styles/account.less @@ -20,6 +20,18 @@ display: block; } + .unsub { + &:hover { + color: @red; + border-color: @red; + }; + + &:active, &.confirming { + background: @red; + color: black; + border: 1px solid black; + } + } .list { letter-spacing: 0.25em; diff --git a/client/assets/styles/styles.less b/client/assets/styles/styles.less index f234fcd0..30b6d8e1 100644 --- a/client/assets/styles/styles.less +++ b/client/assets/styles/styles.less @@ -78,6 +78,10 @@ p { margin-bottom: 1em; } +dl { + margin: 1em 0; +} + #mnml { display: grid; grid-template-columns: minmax(min-content, 1fr) 8fr 1fr; diff --git a/client/src/app.jsx b/client/src/app.jsx index 2e64724f..ddd7a1ea 100644 --- a/client/src/app.jsx +++ b/client/src/app.jsx @@ -30,7 +30,7 @@ document.fonts.load('16pt "Jura"').then(() => { const App = () => ( - + diff --git a/client/src/components/account.management.jsx b/client/src/components/account.management.jsx index 05a8b04b..d20c52a1 100644 --- a/client/src/components/account.management.jsx +++ b/client/src/components/account.management.jsx @@ -18,7 +18,7 @@ const addState = connect( } = state; - function setPassword(current, password) { + function sendSetPassword(current, password) { postData('/account/password', { current, password }) .then(res => res.json()) .then(data => { @@ -29,7 +29,7 @@ const addState = connect( .catch(error => errorToast(error)); } - function setEmail(email) { + function sendSetEmail(email) { postData('/account/email', { email }) .then(res => res.json()) .then(data => { @@ -49,14 +49,19 @@ const addState = connect( return ws.sendMtxConstructSpawn(name); } + function sendSubscriptionCancel() { + return ws.sendSubscriptionCancel(); + } + return { account, ping, email, logout, - setPassword, - setEmail, + sendSetPassword, + sendSetEmail, sendConstructSpawn, + sendSubscriptionCancel, }; }, ); @@ -67,42 +72,73 @@ class AccountStatus extends Component { super(props); this.state = { - setPassword: { current: '', password: '', confirm: ''}, - email: null, + passwordState: { current: '', password: '', confirm: ''}, + emailState: null, + unsubState: false, }; } - render(args) { + render(args, state) { const { account, ping, email, logout, - setPassword, - setEmail, + sendSetEmail, + sendSetPassword, sendConstructSpawn, + sendSubscriptionCancel, } = args; + const { + passwordState, + emailState, + unsubState, + } = state; + if (!account) return null; const passwordsEqual = () => - this.state.setPassword.password === this.state.setPassword.confirm; + passwordState.password === passwordState.confirm; const setPasswordDisabled = () => { - const { current, password, confirm } = this.state.setPassword; + const { current, password, confirm } = passwordState; return !(passwordsEqual() && password && current && confirm); } + const unsub = e => { + if (unsubState) { + return sendSubscriptionCancel(); + } + + e.stopPropagation(); + return this.setState({ unsubState: true }); + } + + const unsubBtn = () => { + if (!account.subscribed) return false; + + const classes = `unsub ${unsubState ? 'confirming' : ''}`; + const text = unsubState ? 'Confirm' : 'Unsubscribe' + return + } + + const tlClick = e => { + e.stopPropagation(); + return this.setState({ unsubState: false }); + } + return ( -