From aeed12cd59c27a23d73a0fef484df00ebd977532 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sat, 20 Jul 2019 22:09:55 +0900
Subject: [PATCH 1/3] refs #969 Reset poll form when toggle the form
---
src/renderer/components/TimelineSpace/Modals/NewToot.vue | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/renderer/components/TimelineSpace/Modals/NewToot.vue b/src/renderer/components/TimelineSpace/Modals/NewToot.vue
index a9812145..f730c91a 100644
--- a/src/renderer/components/TimelineSpace/Modals/NewToot.vue
+++ b/src/renderer/components/TimelineSpace/Modals/NewToot.vue
@@ -149,7 +149,7 @@ export default {
showContentWarning: false,
visibilityList: Visibility,
openPoll: false,
- polls: ['', ''],
+ polls: [],
pollExpire: {
label: this.$t('modals.new_toot.poll.expires.1_day'),
value: 3600 * 24
@@ -354,6 +354,11 @@ export default {
},
togglePollForm() {
this.openPoll = !this.openPoll
+ if (this.openPoll) {
+ this.polls = ['', '']
+ } else {
+ this.polls = []
+ }
},
addPoll() {
this.polls.push('')
From d44651e9e9aea36da23fee4d23e6470bc646dc6a Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sat, 20 Jul 2019 22:21:40 +0900
Subject: [PATCH 2/3] refs #969 Attach poll only specified, and block invalid
poll options
---
src/config/locales/en/translation.json | 3 ++-
.../TimelineSpace/Modals/NewToot.vue | 7 +++++-
src/renderer/errors/validations.js | 2 ++
.../store/TimelineSpace/Modals/NewToot.ts | 23 ++++++++++++++-----
4 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/src/config/locales/en/translation.json b/src/config/locales/en/translation.json
index 6d2b0ef2..2c398bd7 100644
--- a/src/config/locales/en/translation.json
+++ b/src/config/locales/en/translation.json
@@ -406,7 +406,8 @@
"new_toot": {
"toot_length": "Toot length should be {{min}} to {{max}}",
"attach_length": "You can only attach up to {{max}} images",
- "attach_image": "You can only attach images or videos"
+ "attach_image": "You can only attach images or videos",
+ "poll_invalid": "Invalid poll choices"
}
}
}
diff --git a/src/renderer/components/TimelineSpace/Modals/NewToot.vue b/src/renderer/components/TimelineSpace/Modals/NewToot.vue
index f730c91a..d5ff0340 100644
--- a/src/renderer/components/TimelineSpace/Modals/NewToot.vue
+++ b/src/renderer/components/TimelineSpace/Modals/NewToot.vue
@@ -134,7 +134,7 @@ import { clipboard } from 'electron'
import Visibility from '~/src/constants/visibility'
import Status from './NewToot/Status'
import Poll from './NewToot/Poll'
-import { NewTootTootLength, NewTootAttachLength, NewTootModalOpen, NewTootBlockSubmit } from '@/errors/validations'
+import { NewTootTootLength, NewTootAttachLength, NewTootModalOpen, NewTootBlockSubmit, NewTootPollInvalid } from '@/errors/validations'
export default {
name: 'new-toot',
@@ -261,6 +261,11 @@ export default {
message: this.$t('validation.new_toot.attach_length', { max: 4 }),
type: 'error'
})
+ } else if (err instanceof NewTootPollInvalid) {
+ this.$message({
+ message: this.$t('validation.new_toot.poll_invalid'),
+ type: 'error'
+ })
} else if (err instanceof NewTootModalOpen || err instanceof NewTootBlockSubmit) {
// Nothing
} else {
diff --git a/src/renderer/errors/validations.js b/src/renderer/errors/validations.js
index 91f22f76..654eaa11 100644
--- a/src/renderer/errors/validations.js
+++ b/src/renderer/errors/validations.js
@@ -8,6 +8,8 @@ export class NewTootAttachLength extends Error {}
export class NewTootMediaDescription extends Error {}
+export class NewTootPollInvalid extends Error {}
+
export class NewTootUnknownType extends Error {}
export class AuthenticationError extends Error {}
diff --git a/src/renderer/store/TimelineSpace/Modals/NewToot.ts b/src/renderer/store/TimelineSpace/Modals/NewToot.ts
index 17fbeca1..f5d5139b 100644
--- a/src/renderer/store/TimelineSpace/Modals/NewToot.ts
+++ b/src/renderer/store/TimelineSpace/Modals/NewToot.ts
@@ -11,6 +11,7 @@ import {
NewTootTootLength,
NewTootAttachLength,
NewTootMediaDescription,
+ NewTootPollInvalid,
NewTootUnknownType,
AuthenticationError
} from '@/errors/validations'
@@ -205,12 +206,7 @@ const actions: ActionTree = {
status: params.status,
visibility: specifiedVisibility,
sensitive: state.sensitive,
- spoiler_text: params.spoiler,
- poll: {
- expires_in: params.pollExpireSeconds,
- multiple: false,
- options: params.polls
- }
+ spoiler_text: params.spoiler
}
if (state.replyToMessage !== null) {
@@ -219,6 +215,21 @@ const actions: ActionTree = {
})
}
+ if (params.polls.length > 1) {
+ params.polls.map(poll => {
+ if (poll.length < 1) {
+ throw new NewTootPollInvalid()
+ }
+ })
+ form = Object.assign(form, {
+ poll: {
+ expires_in: params.pollExpireSeconds,
+ multiple: false,
+ options: params.polls
+ }
+ })
+ }
+
if (rootState.TimelineSpace.account.accessToken === undefined || rootState.TimelineSpace.account.accessToken === null) {
throw new AuthenticationError()
}
From 3756cd5347459735a401affc205cf58640cce9a3 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sat, 20 Jul 2019 22:25:49 +0900
Subject: [PATCH 3/3] refs #969 Update translation files for poll validations
---
src/config/locales/de/translation.missing.json | 5 +++++
src/config/locales/fr/translation.missing.json | 5 +++++
src/config/locales/it/translation.missing.json | 5 +++++
src/config/locales/ja/translation.json | 3 ++-
src/config/locales/ko/translation.missing.json | 5 +++++
src/config/locales/pl/translation.missing.json | 5 +++++
6 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/config/locales/de/translation.missing.json b/src/config/locales/de/translation.missing.json
index dd9b76ad..ab7630c0 100644
--- a/src/config/locales/de/translation.missing.json
+++ b/src/config/locales/de/translation.missing.json
@@ -92,5 +92,10 @@
"follow_request_accept_error": "Failed to accept the request",
"follow_reuqest_reject_error": "failed to reject the request",
"start_all_streamings_error": "Failed to start streaming of {{domain}}"
+ },
+ "validation": {
+ "new_toot": {
+ "poll_invalid": "Invalid poll choices"
+ }
}
}
diff --git a/src/config/locales/fr/translation.missing.json b/src/config/locales/fr/translation.missing.json
index beb9adfb..a657fa57 100644
--- a/src/config/locales/fr/translation.missing.json
+++ b/src/config/locales/fr/translation.missing.json
@@ -59,5 +59,10 @@
"follow_request_accept_error": "Failed to accept the request",
"follow_reuqest_reject_error": "failed to reject the request",
"start_all_streamings_error": "Failed to start streaming of {{domain}}"
+ },
+ "validation": {
+ "new_toot": {
+ "poll_invalid": "Invalid poll choices"
+ }
}
}
diff --git a/src/config/locales/it/translation.missing.json b/src/config/locales/it/translation.missing.json
index 4d3386b6..3c972902 100644
--- a/src/config/locales/it/translation.missing.json
+++ b/src/config/locales/it/translation.missing.json
@@ -48,5 +48,10 @@
"follow_request_accept_error": "Failed to accept the request",
"follow_reuqest_reject_error": "failed to reject the request",
"start_all_streamings_error": "Failed to start streaming of {{domain}}"
+ },
+ "validation": {
+ "new_toot": {
+ "poll_invalid": "Invalid poll choices"
+ }
}
}
diff --git a/src/config/locales/ja/translation.json b/src/config/locales/ja/translation.json
index 70b12088..e32b262b 100644
--- a/src/config/locales/ja/translation.json
+++ b/src/config/locales/ja/translation.json
@@ -406,7 +406,8 @@
"new_toot": {
"toot_length": "トゥートの長さは {{min}} から {{max}}文字である必要があります",
"attach_length": "添付ファイルは {{max}} つまでです",
- "attach_image": "画像かビデオしか添付できません"
+ "attach_image": "画像かビデオしか添付できません",
+ "poll_invalid": "アンケートに不正な選択肢が含まれています"
}
}
}
diff --git a/src/config/locales/ko/translation.missing.json b/src/config/locales/ko/translation.missing.json
index b29906b1..da2f1e61 100644
--- a/src/config/locales/ko/translation.missing.json
+++ b/src/config/locales/ko/translation.missing.json
@@ -68,5 +68,10 @@
"follow_request_accept_error": "Failed to accept the request",
"follow_reuqest_reject_error": "failed to reject the request",
"start_all_streamings_error": "Failed to start streaming of {{domain}}"
+ },
+ "validation": {
+ "new_toot": {
+ "poll_invalid": "Invalid poll choices"
+ }
}
}
diff --git a/src/config/locales/pl/translation.missing.json b/src/config/locales/pl/translation.missing.json
index 7f0db146..905cd954 100644
--- a/src/config/locales/pl/translation.missing.json
+++ b/src/config/locales/pl/translation.missing.json
@@ -92,5 +92,10 @@
"follow_request_accept_error": "Failed to accept the request",
"follow_reuqest_reject_error": "failed to reject the request",
"start_all_streamings_error": "Failed to start streaming of {{domain}}"
+ },
+ "validation": {
+ "new_toot": {
+ "poll_invalid": "Invalid poll choices"
+ }
}
}