Skip to content

Commit 7ed37f8

Browse files
authored
Merge pull request #451 from cofacts/block-empty-replies
Block empty replies
2 parents 019392e + d70a3d9 commit 7ed37f8

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ By default, the chatbot will be built under `en_US` locale.
135135
During development, changing `LOCALE` in `.env` allows you to spin up dev server under a specific locale.
136136
Please set `LOCALE` to one of `en_US`, `zh_TW` or any other language code that exists under `i18n/` directory.
137137

138+
When previewing translated site on local machine, sometimes the translated text does not appear.
139+
You may need to set `BABEL_DISABLE_CACHE` (example: `BABEL_DISABLE_CACHE=1 npm run dev`) to disable
140+
babel cache for the new translation to appear correctly.
141+
138142
When building using Docker, `LOCALE` can be provided via build args.
139143

140144
## Legal

components/NewReplySection/index.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,20 @@ const NewReplySection = withContext(
105105
const { replyType: type, reference, text } = fields;
106106
e.preventDefault(); // prevent reload
107107
if (creatingReply) return;
108+
109+
const trimmedText = text.trim();
110+
if (trimmedText.length === 0) {
111+
alert(t`Please provide reply text.`);
112+
return;
113+
}
114+
108115
createReply({
109-
variables: { type, reference, text, articleId: article.id },
116+
variables: {
117+
type,
118+
reference,
119+
text: trimmedText,
120+
articleId: article.id,
121+
},
110122
});
111123
},
112124
[createReply, fields, article.id, creatingReply]

i18n/zh_TW.po

+5-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ msgstr "感謝您的意見。"
146146
msgid "Your reply has been submitted."
147147
msgstr "已經送出回應。"
148148

149-
#: components/NewReplySection/index.js:125
149+
#: components/NewReplySection/index.js:137
150150
#: lib/apollo.js:47
151151
msgid "Please login first."
152152
msgstr "請先登入。"
@@ -2373,6 +2373,10 @@ msgstr ""
23732373
"2016 年起將 chatbot 導入事實查核領域、並提供 API "
23742374
"介接教學,在此領域激起了典範轉移,專業查核組織開始推出自己的chatbot,也有第三方查詢機器人前來介接 Cofacts 資料。"
23752375

2376+
#: components/NewReplySection/index.js:111
2377+
msgid "Please provide reply text."
2378+
msgstr "請提供回應文字。"
2379+
23762380
#: pages/index.js:29
23772381
msgctxt "site title"
23782382
msgid "Cofacts"

0 commit comments

Comments
 (0)