Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for sending info about address-less creators #159

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 33 additions & 1 deletion src/dashboard/components/DonationSummaryComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ div.pt-2
single-line,
autofocus)

div.text-xs-center.pt-2.pb-3
v-layout(column, align-center).pt-2.pb-3
v-btn(v-if="!buttonError", large, outline, color='primary', v-on:click="donateAll()")
| Send your thanks! (${{ total.toFixed(2) }})
v-btn(v-else, disabled, large, outline, color='primary', v-on:click="donateAll()")
| {{ buttonError }}
v-checkbox(label="Send the Thankful devs info about creators with missing addresses" v-model="shouldSendAddressLess")
</template>

<script>
Expand All @@ -78,6 +79,7 @@ export default {
v => !v || this.isAddress(v) || 'Not a valid ETH address',
],
},
shouldSendAddressLess: true,
};
},
computed: {
Expand Down Expand Up @@ -126,8 +128,38 @@ export default {
donateAll() {
this.$store
.dispatch('metamask/donateAll', this.distribution)
.then(() => {
if (this.shouldSendAddressLess) {
return this.sendAddressLess();
}
})
.catch(e => this.$emit('error', e));
},
async sendAddressLess() {
try {
const addressLess = _.filter(
this.distribution,
c => c.address === undefined
).map(c => _.pick(c, ['url', 'funds']));

// TODO: Add the actual server here
const server = 'http://localhost:5000';
const res = await fetch(
server + '/missing/?missing_info=' + JSON.stringify(addressLess),
{ method: 'POST' }
);

if (res.status !== 200) {
console.error(
`Unexpected address-less creator response, status: ${
res.status
}, message: ${await res.text()}`
);
}
} catch (err) {
console.error('Failed to send address-less creators:' + err);
}
},
},
created() {
this.distribute();
Expand Down
3 changes: 3 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ module.exports = {
}),
],
devtool: 'cheap-module-eval-source-map',
watchOptions: {
poll: true,
},
optimization: {
minimizer: [
new UglifyJsPlugin({
Expand Down