Skip to content

Commit

Permalink
fix: fix #2597 (#2598)
Browse files Browse the repository at this point in the history
  • Loading branch information
qgy18 authored Jul 6, 2024
1 parent 373fb03 commit 8c7c5ec
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
50 changes: 26 additions & 24 deletions packages/client/src/components/CommentBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -220,33 +220,35 @@ const submitComment = async (): Promise<void> => {
ua,
};
// https://github.com/walinejs/waline/issues/2163
if (userInfo.value?.token && !props.edit) {
// login user
comment.nick = userInfo.value.display_name;
comment.mail = userInfo.value.email;
comment.link = userInfo.value.url;
} else {
if (login === 'force') return;
// check nick
if (requiredMeta.indexOf('nick') > -1 && !comment.nick) {
inputRefs.value.nick?.focus();
return alert(locale.value.nickError);
}
if (!props.edit) {
// https://github.com/walinejs/waline/issues/2163
if (userInfo.value?.token) {
// login user
comment.nick = userInfo.value.display_name;
comment.mail = userInfo.value.email;
comment.link = userInfo.value.url;
} else {
if (login === 'force') return;
// check mail
if (
(requiredMeta.indexOf('mail') > -1 && !comment.mail) ||
(comment.mail && !isValidEmail(comment.mail))
) {
inputRefs.value.mail?.focus();
// check nick
if (requiredMeta.indexOf('nick') > -1 && !comment.nick) {
inputRefs.value.nick?.focus();
return alert(locale.value.mailError);
}
return alert(locale.value.nickError);
}
if (!comment.nick) comment.nick = locale.value.anonymous;
// check mail
if (
(requiredMeta.indexOf('mail') > -1 && !comment.mail) ||
(comment.mail && !isValidEmail(comment.mail))
) {
inputRefs.value.mail?.focus();
return alert(locale.value.mailError);
}
if (!comment.nick) comment.nick = locale.value.anonymous;
}
}
// check comment
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/components/WalineComment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ onUnmounted(() => abort?.());
<div data-waline>
<Reaction />

<CommentBox v-if="!reply" @log="refresh" @submit="onSubmit" />
<CommentBox v-if="!reply && !edit" @log="refresh" @submit="onSubmit" />

<div class="wl-meta-head">
<div class="wl-count">
Expand Down

0 comments on commit 8c7c5ec

Please sign in to comment.