Skip to content

Commit 6c05892

Browse files
committed
better dev tooling for verify view
1 parent 7a8d607 commit 6c05892

File tree

7 files changed

+52
-30
lines changed

7 files changed

+52
-30
lines changed

bin/buy.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
<div class="gumroad-product-embed" data-gumroad-product-id="fgSJ">
2121
<p id='loadingP'></p>
2222
</div>
23-
<script src="common.bundle.js"></script>
2423
<script src='buy.js'></script>
2524
</body>
2625
</html>

bin/verify.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
</head>
3535
<body>
3636
<div id='verify__react__root'></div>
37-
<script src="common.bundle.js"></script>
3837
<script src="verify.bundle.js"></script>
3938
</body>
4039
</html>

example.pltr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@
646646
"dirty": true,
647647
"fileName": "/Users/sparrowhawk/github/plottr_electron/example.pltr",
648648
"loaded": true,
649-
"version": "1.4.24"
649+
"version": "1.4.26"
650650
},
651651
"lines": [
652652
{

locales/en.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,14 @@
206206
"Hide Plottr": {
207207
"message": "Hide Plottr"
208208
},
209+
"Hmmmm. It looks like that's not a valid license key": {
210+
"message": "Hmmmm. It looks like that's not a valid license key"
211+
},
209212
"If you keep seeing this problem, email me at [email protected]": {
210213
"message": "If you keep seeing this problem, email me at [email protected]"
211214
},
212-
"It looks like you have Plottr on 5 computers already or you requested a refund": {
213-
"message": "It looks like you have Plottr on 5 computers already or you requested a refund"
215+
"It looks like you have Plottr on 5 computers already": {
216+
"message": "It looks like you have Plottr on 5 computers already"
214217
},
215218
"It looks like you have an older file version. This could make things work funky or not at all. May Plottr update it for you?": {
216219
"message": "It looks like you have an older file version. This could make things work funky or not at all. May Plottr update it for you?"

locales/fr.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@
209209
"Hide Plottr": {
210210
"message": "Cacher Plottr"
211211
},
212-
"Hmmmm. It looks like that's not a valid license key.": {
213-
"message": "Hmmm. Il semble que ce n'est pas une clef de licence valable."
212+
"Hmmmm. It looks like that's not a valid license key": {
213+
"message": "Hmmm. Il semble que ce n'est pas une clef de licence valable"
214214
},
215215
"If you keep seeing this problem, email me at [email protected]": {
216216
"message": "Si le problème se répète, merci de m''écrire à [email protected]"
217217
},
218-
"It looks like you have Plottr on 5 computers already or you requested a refund": {
219-
"message": "Il semble que vous avez installé Plottr sur 5 ordinateurs ou que vous vous êtes fait rembourser."
218+
"It looks like you have Plottr on 5 computers already": {
219+
"message": "Il semble que vous avez installé Plottr sur 5 ordinateurs"
220220
},
221221
"It looks like you have an older file version. This could make things work funky or not at all. May Plottr update it for you?": {
222222
"message": "Il semble que vous avez une version ancienne du fichier. Le logiciel pourrait fonctionner étrangement ou pas du tout. Plottr peut-il faire une mise à jour pour vous?"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"repository": "https://github.com/cameronsutter/plottr_electron.git",
55
"private": true,
66
"readme": "Copyright 2016 C. Louis S. (Cameron Sutter)",
7-
"version": "1.4.26",
7+
"version": "1.4.27",
88
"author": {
99
"name": "C. Louis S.",
1010
"email": "[email protected]",

src/verify/VerifyView.js

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import i18n from 'format-message'
1010
const SUCCESS = 'success'
1111
const OFFLINE = 'offline'
1212
const INVALID = 'invalid'
13+
const TOOMANY = 'toomany'
1314
const CANTSAVE = 'cantsave'
1415
const SAVE2 = 'save_attempt_2'
1516
const RED = 'bg-danger'
@@ -33,8 +34,9 @@ class VerifyView extends Component {
3334
} else if (value === OFFLINE) {
3435
return i18n("It looks like you're not online. You don't always have to be online to user Plottr, but it can't verify your license offline")
3536
} else if (value === INVALID) {
36-
return i18n('It looks like you have Plottr on 5 computers already or you requested a refund')
37-
// return i18n("Hmmmm. It looks like that's not a valid license key.")
37+
return i18n("Hmmmm. It looks like that's not a valid license key")
38+
} else if (value === TOOMANY) {
39+
return i18n('It looks like you have Plottr on 5 computers already')
3840
} else if (value === CANTSAVE) {
3941
return i18n("Plottr verified your license key successfully, but there was an error saving that. Let's try one more time")
4042
} else if (value === SAVE2) {
@@ -44,7 +46,11 @@ class VerifyView extends Component {
4446
}
4547
}
4648

47-
verifyLicense (license) {
49+
isValidLicense = (body) => {
50+
return body.success && !body.purchase.refunded && !body.purchase.chargebacked && !body.purchase.disputed
51+
}
52+
53+
verifyLicense = (license) => {
4854
var req = {
4955
url: 'https://api.gumroad.com/v2/licenses/verify',
5056
method: 'POST',
@@ -54,31 +60,46 @@ class VerifyView extends Component {
5460
license_key: license
5561
}
5662
}
63+
if (process.env.NODE_ENV === 'development') {
64+
req.body.increment_uses_count = 'false'
65+
}
5766
const view = this
5867
request(req, function (err, response, body) {
5968
var newState = {spinnerHidden: true}
6069
if (err && err.code === 404) {
6170
newState.showAlert = true
6271
newState.alertText = view.makeAlertText(INVALID)
6372
} else {
64-
if (body.success && !body.purchase.refunded && !body.purchase.chargebacked && body.uses <= 5) {
65-
// save uses, purchase.email, purchase.full_name, purchase.variants
66-
storage.set('user_info', body, function(err) {
67-
if (err) {
68-
view.setState({showAlert: true, alertText: view.makeAlertText(CANTSAVE)})
69-
storage.set('user_info', body, function(err) {
70-
if (err) {
71-
view.setState({showAlert: true, alertText: view.makeAlertText(SAVE2)})
72-
} else {
73-
view.setState({showAlert: true, alertClass: GREEN, alertText: view.makeAlertText(SUCCESS)})
73+
if (process.env.NODE_ENV === 'development') {
74+
console.log(body)
75+
}
76+
if (view.isValidLicense(body)) {
77+
if (body.uses > 5) {
78+
newState.showAlert = true
79+
newState.alertText = view.makeAlertText(TOOMANY)
80+
} else {
81+
// save uses, purchase.email, purchase.full_name, purchase.variants
82+
storage.set('user_info', body, function(err) {
83+
if (err) {
84+
view.setState({showAlert: true, alertText: view.makeAlertText(CANTSAVE)})
85+
storage.set('user_info', body, function(err) {
86+
if (err) {
87+
view.setState({showAlert: true, alertText: view.makeAlertText(SAVE2)})
88+
} else {
89+
view.setState({showAlert: true, alertClass: GREEN, alertText: view.makeAlertText(SUCCESS)})
90+
if (process.env.NODE_ENV !== 'development') {
91+
ipcRenderer.send('license-verified')
92+
}
93+
}
94+
})
95+
} else {
96+
view.setState({showAlert: true, alertClass: GREEN, alertText: view.makeAlertText(SUCCESS)})
97+
if (process.env.NODE_ENV !== 'development') {
7498
ipcRenderer.send('license-verified')
75-
}
76-
})
77-
} else {
78-
view.setState({showAlert: true, alertClass: GREEN, alertText: view.makeAlertText(SUCCESS)})
79-
ipcRenderer.send('license-verified')
80-
}
81-
})
99+
}
100+
}
101+
})
102+
}
82103
} else {
83104
newState.showAlert = true
84105
newState.alertText = view.makeAlertText(INVALID)

0 commit comments

Comments
 (0)