fix(deps): update dependency eslint-plugin-react-hooks to v5 (#1280)

* fix(deps): update dependency eslint-plugin-react-hooks to v5

* fix: lint issues after reenabling hook rules

* fix: format issues

---------

Co-authored-by: homarr-renovate[bot] <158783068+homarr-renovate[bot]@users.noreply.github.com>
Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
This commit is contained in:
homarr-renovate[bot]
2024-10-16 21:43:51 +02:00
committed by GitHub
parent ea43ed0ca4
commit a87c937b69
39 changed files with 251 additions and 224 deletions

View File

@@ -189,17 +189,31 @@ export function Notebook({ options, isEditMode, boardId, itemId }: WidgetCompone
addEventListener("onReadOnlyCheck", handleOnReadOnlyCheck);
const handleEditToggleCallback = (previous: boolean) => {
const current = !previous;
if (!editor) return current;
editor.setEditable(current);
const handleContentUpdate = useCallback(
(contentUpdate: string) => {
setToSaveContent(contentUpdate);
// This is not available in preview mode
if (boardId && itemId) {
void mutateAsync({ boardId, itemId, content: contentUpdate });
}
},
[boardId, itemId, mutateAsync],
);
handleContentUpdate(content);
const handleEditToggleCallback = useCallback(
(previous: boolean) => {
const current = !previous;
if (!editor) return current;
editor.setEditable(current);
return current;
};
handleContentUpdate(content);
const handleEditCancelCallback = () => {
return current;
},
[content, editor, handleContentUpdate],
);
const handleEditCancelCallback = useCallback(() => {
if (!editor) return false;
editor.setEditable(false);
@@ -207,20 +221,12 @@ export function Notebook({ options, isEditMode, boardId, itemId }: WidgetCompone
editor.commands.setContent(toSaveContent);
return false;
};
}, [editor, toSaveContent]);
const handleEditCancel = useCallback(() => {
setIsEditing(handleEditCancelCallback);
}, [setIsEditing, handleEditCancelCallback]);
const handleContentUpdate = (contentUpdate: string) => {
setToSaveContent(contentUpdate);
// This is not available in preview mode
if (boardId && itemId) {
void mutateAsync({ boardId, itemId, content: contentUpdate });
}
};
const handleEditToggle = useCallback(() => {
setIsEditing(handleEditToggleCallback);
}, [setIsEditing, handleEditToggleCallback]);