From a9bdf9c281a88363b76b9a86e5bce94970cd806c Mon Sep 17 00:00:00 2001 From: notfire Date: Thu, 2 Jan 2025 21:10:43 -0500 Subject: [PATCH] raise poll choice limit to 20 and allow polls from 1 second to 1000 years --- src/components/poll/poll_form.js | 6 +++++- src/modules/instance.js | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/poll/poll_form.js b/src/components/poll/poll_form.js index 89f01eb4..a2b4c328 100644 --- a/src/components/poll/poll_form.js +++ b/src/components/poll/poll_form.js @@ -35,7 +35,7 @@ export default { return this.pollLimits.max_option_chars }, expiryUnits () { - const allUnits = ['minutes', 'hours', 'days'] + const allUnits = ['seconds', 'minutes', 'hours', 'days', 'years'] const expiry = this.convertExpiryFromUnit return allUnits.filter( unit => this.pollLimits.max_expiration >= expiry(unit, 1) @@ -95,17 +95,21 @@ export default { convertExpiryToUnit (unit, amount) { // Note: we want seconds and not milliseconds switch (unit) { + case 'seconds': return (1000 * amount) / DateUtils.SECOND case 'minutes': return (1000 * amount) / DateUtils.MINUTE case 'hours': return (1000 * amount) / DateUtils.HOUR case 'days': return (1000 * amount) / DateUtils.DAY + case 'years': return (1000 * amount) / DateUtils.YEAR } }, convertExpiryFromUnit (unit, amount) { // Note: we want seconds and not milliseconds switch (unit) { + case 'seconds': return amount * DateUtils.SECOND / 1000 case 'minutes': return amount * DateUtils.MINUTE / 1000 case 'hours': return amount * DateUtils.HOUR / 1000 case 'days': return amount * DateUtils.DAY / 1000 + case 'years': return amount * DateUtils.YEAR / 1000 } }, expiryAmountChange () { diff --git a/src/modules/instance.js b/src/modules/instance.js index ff59d1e6..5c3fc1c9 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -100,10 +100,10 @@ const defaultState = { pollsAvailable: false, pollLimits: { - max_options: 4, + max_options: 20, max_option_chars: 255, - min_expiration: 60, - max_expiration: 60 * 60 * 24 + min_expiration: 1, + max_expiration: 60 * 60 * 24 * 365 * 1000 } }