Skip to content
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

[HOLD] Readd Composer logs #44290

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/components/Composer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import updateIsFullComposerAvailable from '@libs/ComposerUtils/updateIsFullCompo
import * as EmojiUtils from '@libs/EmojiUtils';
import * as FileUtils from '@libs/fileDownload/FileUtils';
import isEnterWhileComposition from '@libs/KeyboardShortcut/isEnterWhileComposition';
import Log from '@libs/Log';
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager';
import CONST from '@src/CONST';
import type {ComposerProps} from './types';
Expand Down Expand Up @@ -106,11 +107,22 @@ function Composer(
const isScrollBarVisible = useIsScrollBarVisible(textInput, value ?? '');
const [prevScroll, setPrevScroll] = useState<number | undefined>();

// Those useEffects track changes of `shouldClear` and `onClear` independently.
useEffect(() => {
Log.info('[Composer] `shouldClear` value changed', true, {shouldClear});
}, [shouldClear]);

useEffect(() => {
Log.info('[Composer] `onClear` value changed', true, {shouldClear});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [onClear]);

useEffect(() => {
if (!shouldClear) {
return;
}
textInput.current?.clear();
Log.info('[Composer] `textInput` cleared', true, {shouldClear});
onClear();
}, [shouldClear, onClear]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import * as EmojiUtils from '@libs/EmojiUtils';
import focusComposerWithDelay from '@libs/focusComposerWithDelay';
import getPlatform from '@libs/getPlatform';
import * as KeyDownListener from '@libs/KeyboardShortcut/KeyDownPressListener';
import Log from '@libs/Log';
import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser';
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
Expand Down Expand Up @@ -277,6 +278,7 @@ function ComposerWithSuggestions(
const tag = useSharedValue(-1);
const draftComment = getDraftComment(reportID) ?? '';
const [value, setValue] = useState(() => {
Log.info('[ComposerWithSuggestions] Initializing state `value` with draftComment', true, {draftComment});
if (draftComment) {
emojisPresentBefore.current = EmojiUtils.extractEmojis(draftComment);
}
Expand Down Expand Up @@ -434,6 +436,7 @@ function ComposerWithSuggestions(
setIsCommentEmpty(isNewCommentEmpty);
}
emojisPresentBefore.current = emojis;
Log.info('[ComposerWithSuggestions] Setting new comment value', true, {newValue: newCommentConverted, oldValue: value});
setValue(newCommentConverted);
if (commentValue !== newComment) {
const position = Math.max((selection.end ?? 0) + (newComment.length - commentRef.current.length), cursorPosition ?? 0);
Expand Down Expand Up @@ -461,6 +464,8 @@ function ComposerWithSuggestions(
debouncedBroadcastUserIsTyping(reportID);
}
},
// We don't want to have `value` in dependencies since it is only used in Log.info
// eslint-disable-next-line react-hooks/exhaustive-deps
[
debouncedUpdateFrequentlyUsedEmojis,
findNewlyAddedChars,
Expand Down Expand Up @@ -492,12 +497,15 @@ function ComposerWithSuggestions(

setSelection({start: 0, end: 0, positionX: 0, positionY: 0});
updateComment('');
Log.info('[ComposerWithSuggestions] `textInputShouldClear` changed to true', true, {oldTextInputShouldClear: textInputShouldClear});
setTextInputShouldClear(true);
if (isComposerFullSize) {
Report.setIsComposerFullSize(reportID, false);
}
setIsFullComposerAvailable(false);
return trimmedComment;
// We don't want to have `textInputShouldClear` in dependencies since it is only used in Log.info
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [updateComment, setTextInputShouldClear, isComposerFullSize, setIsFullComposerAvailable, reportID, debouncedSaveReportComment]);

/**
Expand Down Expand Up @@ -742,6 +750,7 @@ function ComposerWithSuggestions(
);

const onClear = useCallback(() => {
Log.info('[ComposerWithSuggestions] `onClear` called', true);
setTextInputShouldClear(false);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import canFocusInputOnScreenFocus from '@libs/canFocusInputOnScreenFocus';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import {getDraftComment} from '@libs/DraftCommentUtils';
import getModalState from '@libs/getModalState';
import Log from '@libs/Log';
import * as ReportUtils from '@libs/ReportUtils';
import playSound, {SOUNDS} from '@libs/Sound';
import willBlurTextInputOnTapOutsideFunc from '@libs/willBlurTextInputOnTapOutside';
Expand Down Expand Up @@ -160,6 +161,7 @@ function ReportActionCompose({
const [textInputShouldClear, setTextInputShouldClear] = useState(false);
const [isCommentEmpty, setIsCommentEmpty] = useState(() => {
const draftComment = getDraftComment(reportID);
Log.info('[ReportActionCompose] Initializing state `isCommentEmpty` with value that depends on draftComment', true, {draftComment});
return !draftComment || !!draftComment.match(/^(\s)*$/);
});

Expand Down Expand Up @@ -267,8 +269,11 @@ function ReportActionCompose({
playSound(SOUNDS.DONE);
const newComment = composerRef?.current?.prepareCommentAndResetComposer();
Report.addAttachment(reportID, file, newComment);
Log.info('[ReportActionCompose] `textInputShouldClear` changed to false', true, {oldTextInputShouldClear: textInputShouldClear});
setTextInputShouldClear(false);
},
// We don't want to have `textInputShouldClear` in dependencies since it is only used in Log.info
// eslint-disable-next-line react-hooks/exhaustive-deps
[reportID],
);

Expand Down
Loading