-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imprv: Show unsaved warning when comment not posted #7603
imprv: Show unsaved warning when comment not posted #7603
Conversation
…ge when commenting
const onChangeHandler = useCallback((newValue: string, isClean: boolean) => { | ||
setComment(newValue); | ||
mutateIsEnabledUnsavedWarning(!isClean); | ||
}, [mutateIsEnabledUnsavedWarning]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
post しても引き続き browser warning がでます。ご確認お願いします。
comment post 後に渡る値を見てみると newValue は ですが, isClean は false でわたってくるようです。 -
Reply と Add Comment の CommentEditor が同時に呼ばれる場合があるのでどちらかに not posted な値があるときは browser warning を出すようにしてください。(両方に入力してから片方 post したら warning されない気がする。)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
対応しました。
const initializeEditor = useCallback(async() => { | ||
setComment(''); | ||
setActiveTab('comment_editor'); | ||
setError(undefined); | ||
initializeSlackEnabled(); | ||
// reset value | ||
if (editorRef.current == null) { return } | ||
editorRef.current.setValue(''); | ||
}, [initializeSlackEnabled]); | ||
const editingCommentsNum = await decrementEditingCommentsNum(); | ||
if (editingCommentsNum === 0) { | ||
mutateIsEnabledUnsavedWarning(false); // must be after clearing comment or else onChange will override bool | ||
} | ||
}, [initializeSlackEnabled, mutateIsEnabledUnsavedWarning, decrementEditingCommentsNum]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cancelButtonClickedHandler() 内でもこの initializeEditor() 呼ぶようにしてください。
(なぜこれまで呼ばれてなかったんだろう。呼んでもいいはず。デグレがないか確認していただけるとありがたいです。)
apps/app/src/stores/comment.tsx
Outdated
|
||
return { | ||
...swrResponse, | ||
increment: () => swrResponse.mutate(swrResponse.data ? swrResponse.data + 1 : 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
細かいけど、
コーディングガイド的には三項演算子の条件に使うなら != null
と明示したい。
完結に書くなら (swrResponse.data ?? 0) + 1
でよさそう。
apps/app/src/stores/comment.tsx
Outdated
if (swrResponse.data != null && swrResponse.data > 0) { | ||
return swrResponse.mutate(swrResponse.data - 1); | ||
} | ||
return swrResponse.mutate(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こちらも完結に、
const newValue = (swrResponse.data ?? 0) - 1);
mutate(Math.max(0, newValue))`;
reg-suit detected visual differences. Check this report, and review them. 🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴 What do the circles mean?The number of circles represent the number of changed images.🔴 : Changed items, ⚪ : New items, ⚫ : Deleted items, and 🔵 Passed items How can I change the check status?If reviewers approve this PR, the reg context status will be green automatically. |
review task
https://redmine.weseek.co.jp/issues/121003
動作イメージ
コメント編集中も同様