Skip to content

Commit

Permalink
fix(raffles): show proper widget tickets if raffle is running (#3592)
Browse files Browse the repository at this point in the history
Fixes #3589
  • Loading branch information
sogehige committed May 3, 2020
1 parent 8c168ab commit fc60b10
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/panel/widgets/components/raffles.vue
Expand Up @@ -124,7 +124,7 @@
div.input-group
div.input-group-prepend
span.input-group-text max
input(type="number" v-model.number="ticketsMax" class="form-control" placeholder="100" id="maxTickets" :min="String(ticketsMin)" :disabled="running")
input(type="number" v-model.number="ticketsMax" class="form-control" placeholder="100" id="maxTickets" min="1" :disabled="running")

b-tab(v-if="winner")
template(v-slot:title)
Expand Down Expand Up @@ -304,6 +304,22 @@ export default {
},
keyword: function () {
if (!this.keyword.startsWith('!')) this.keyword = '!' + this.keyword
},
ticketsMax(val) {
if (val < this.ticketsMin) {
this.ticketsMin = this.ticketsMax;
}
if (val < 1) {
this.ticketsMax = 1;
}
},
ticketsMin(val) {
if (val > this.ticketsMax) {
this.ticketsMax = this.ticketsMin;
}
if (val < 1) {
this.ticketsMin = 1;
}
}
},
methods: {
Expand All @@ -322,6 +338,9 @@ export default {
await Promise.all([
new Promise((resolve, reject) => {
this.socket.emit('raffle:getLatest', (err, raffle) => {
console.groupCollapsed('raffle:getLatest')
console.log({err, raffle})
console.groupEnd();
if (err) {
reject(err);
}
Expand All @@ -346,8 +365,8 @@ export default {
if (this.running) {
this.keyword = raffle.keyword
this.isTypeKeywords = raffle.type === 0
this.ticketsMax = raffle.max
this.ticketsMin = raffle.min
this.ticketsMax = raffle.maxTickets
this.ticketsMin = raffle.minTickets
// set eligibility
if (!raffle.subscribers && !raffle.followers) {
Expand Down

0 comments on commit fc60b10

Please sign in to comment.