Commit 2e26f163 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Fix JSDoc typing for `useCallback`-wrapped callbacks

parent 5370c39d
...@@ -57,19 +57,21 @@ function AnnotationEditor({ ...@@ -57,19 +57,21 @@ function AnnotationEditor({
const isEmpty = !text && !tags.length; const isEmpty = !text && !tags.length;
const onEditTags = useCallback( const onEditTags = useCallback(
/** @param {string[]} tags */
tags => { tags => {
store.createDraft(draft.annotation, { ...draft, tags }); store.createDraft(draft.annotation, { ...draft, tags });
}, },
[draft, store] [draft, store]
); );
/**
* Verify `newTag` has content and is not a duplicate; add the tag
*
* @param {string} newTag
* @return {boolean} - `true` if tag is added
*/
const onAddTag = useCallback( const onAddTag = useCallback(
/**
* Verify `newTag` has content and is not a duplicate; add the tag
*
* @param {string} newTag
* @return {boolean} Tag was added to the draft's tags; `false` if duplicate
* or empty
*/
newTag => { newTag => {
if (!newTag || tags.indexOf(newTag) >= 0) { if (!newTag || tags.indexOf(newTag) >= 0) {
// don't add empty or duplicate tags // don't add empty or duplicate tags
...@@ -84,13 +86,13 @@ function AnnotationEditor({ ...@@ -84,13 +86,13 @@ function AnnotationEditor({
[onEditTags, tags, tagsService] [onEditTags, tags, tagsService]
); );
/**
* Remove a tag from the annotation.
*
* @param {string} tag
* @return {boolean} - `true` if tag extant and removed
*/
const onRemoveTag = useCallback( const onRemoveTag = useCallback(
/**
* Remove tag from draft if present.
*
* @param {string} tag
* @return {boolean} Tag removed from draft
*/
tag => { tag => {
const newTagList = [...tags]; // make a copy const newTagList = [...tags]; // make a copy
const index = newTagList.indexOf(tag); const index = newTagList.indexOf(tag);
...@@ -115,6 +117,7 @@ function AnnotationEditor({ ...@@ -115,6 +117,7 @@ function AnnotationEditor({
* @param {boolean} isPrivate * @param {boolean} isPrivate
*/ */
const onSetPrivate = useCallback( const onSetPrivate = useCallback(
/** @param {boolean} isPrivate */
isPrivate => { isPrivate => {
store.createDraft(annotation, { store.createDraft(annotation, {
...draft, ...draft,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment