Tell user when linked-comment is not available.

This commit is contained in:
infinite-persistence 2021-07-14 12:52:33 +08:00
parent e77a986125
commit 4731588a3c
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 12 additions and 2 deletions

View file

@ -1445,6 +1445,7 @@
"You loved this": "You loved this", "You loved this": "You loved this",
"Creator loved this": "Creator loved this", "Creator loved this": "Creator loved this",
"A channel is required to throw fire and slime": "A channel is required to throw fire and slime", "A channel is required to throw fire and slime": "A channel is required to throw fire and slime",
"The requested comment is no longer available.": "The requested comment is no longer available.",
"Best": "Best", "Best": "Best",
"Controversial": "Controversial", "Controversial": "Controversial",
"Show Replies": "Show Replies", "Show Replies": "Show Replies",

View file

@ -105,7 +105,7 @@ export function doCommentList(
}; };
} }
export function doCommentById(commentId: string) { export function doCommentById(commentId: string, toastIfNotFound: boolean = true) {
return (dispatch: Dispatch, getState: GetState) => { return (dispatch: Dispatch, getState: GetState) => {
return Comments.comment_by_id({ comment_id: commentId, with_ancestors: true }) return Comments.comment_by_id({ comment_id: commentId, with_ancestors: true })
.then((result: CommentByIdResponse) => { .then((result: CommentByIdResponse) => {
@ -122,7 +122,16 @@ export function doCommentById(commentId: string) {
return result; return result;
}) })
.catch((error) => { .catch((error) => {
devToast(dispatch, error.message); if (error.message === 'sql: no rows in result set' && toastIfNotFound) {
dispatch(
doToast({
isError: true,
message: __('The requested comment is no longer available.'),
})
);
} else {
devToast(dispatch, error.message);
}
}); });
}; };
} }