Show comment failure reason

## Issue
6370
This commit is contained in:
infinite-persistence 2021-07-03 23:56:41 +08:00 committed by jessopb
parent 22d9495b8d
commit 10c04a7991
2 changed files with 22 additions and 7 deletions

View file

@ -1437,6 +1437,8 @@
"Show Replies": "Show Replies",
"Unable to create comment, please try again later.": "Unable to create comment, please try again later.",
"Unable to comment. This channel has blocked you.": "Unable to comment. This channel has blocked you.",
"Unable to comment. Your channel has been blocked by an admin.": "Unable to comment. Your channel has been blocked by an admin.",
"Unable to comment. The content owner has disabled comments.": "Unable to comment. The content owner has disabled comments.",
"The comment contains contents that are blocked by %author%": "The comment contains contents that are blocked by %author%",
"Your channel is still being setup, try again in a few moments.": "Your channel is still being setup, try again in a few moments.",
"Unable to delete this comment, please try again later.": "Unable to delete this comment, please try again later.",

View file

@ -329,13 +329,26 @@ export function doCommentCreate(
}
if (error) {
const BLOCKED_WORDS_ERR_MSG = 'the comment contents are blocked by';
if (error.message === 'channel is blocked by publisher') {
toastMessage = __('Unable to comment. This channel has blocked you.');
} else if (error.message.startsWith(BLOCKED_WORDS_ERR_MSG)) {
const channelName = error.message.substring(BLOCKED_WORDS_ERR_MSG.length);
toastMessage = __('The comment contains contents that are blocked by %author%', { author: channelName });
// TODO: Use error codes when commentron implements it.
switch (error.message) {
case 'channel is blocked by publisher':
toastMessage = __('Unable to comment. This channel has blocked you.');
break;
case 'channel is not allowed to post comments':
toastMessage = __('Unable to comment. Your channel has been blocked by an admin.');
break;
case 'comments are disabled by the creator':
toastMessage = __('Unable to comment. The content owner has disabled comments.');
break;
default:
const BLOCKED_WORDS_ERR_MSG = 'the comment contents are blocked by';
if (error.message.startsWith(BLOCKED_WORDS_ERR_MSG)) {
const channelName = error.message.substring(BLOCKED_WORDS_ERR_MSG.length);
toastMessage = __('The comment contains contents that are blocked by %author%', {
author: channelName,
});
}
break;
}
}