From ac7946ddc2dad87de62b001ebe551f3f87c561b1 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 16 Aug 2023 15:48:50 +0200 Subject: [PATCH] Don't send title change request if no changes have been applied --- .../board/[board]/(page)/useBoardMetadataEditor.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/todoblue/src/app/[lang]/board/[board]/(page)/useBoardMetadataEditor.ts b/todoblue/src/app/[lang]/board/[board]/(page)/useBoardMetadataEditor.ts index a9d33df..6d21dfe 100644 --- a/todoblue/src/app/[lang]/board/[board]/(page)/useBoardMetadataEditor.ts +++ b/todoblue/src/app/[lang]/board/[board]/(page)/useBoardMetadataEditor.ts @@ -17,10 +17,12 @@ export function useBoardMetadataEditor() { const stopEditingMetadata = useCallback(() => { console.debug("[useEditableTitle] Ending title edit..."); setEditingMetadata(false); - console.debug("[useEditableTitle] Sending title change request..."); - const request: TitleBoardRequest = {"Title": titleFromEditor} - sendRequest(request) - }, [sendRequest, titleFromEditor]) + if(titleFromState !== titleFromEditor) { + console.debug("[useEditableTitle] Sending title change request..."); + const request: TitleBoardRequest = {"Title": titleFromEditor} + sendRequest(request) + } + }, [sendRequest, titleFromState, titleFromEditor]) const toggleEditingMetadata = useCallback(() => { return isEditingMetadata ? stopEditingMetadata() : startEditingMetadata()