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

Add LHN debugging to Debug Mode #48442

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
34 changes: 17 additions & 17 deletions src/components/TimePicker/TimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type TimePickerProps = {
/** Whether the time value should be validated */
shouldValidate?: boolean;

/** Whether the picker shows hours, minutes, seconds and miliseconds */
/** Whether the picker shows hours, minutes, seconds and milliseconds */
showFullFormat?: boolean;
};

Expand Down Expand Up @@ -88,7 +88,7 @@ function replaceRangeWithZeros(originalString: string, from: number, to: number,
}

/**
* Clear the value under selection of an input (either hours, minutes, seconds or miliseconds) by replacing it with zeros
* Clear the value under selection of an input (either hours, minutes, seconds or milliseconds) by replacing it with zeros
*
* @param value - current value of the input
* @param selection - current selection of the input
Expand Down Expand Up @@ -135,7 +135,7 @@ function TimePicker({defaultValue = '', onSubmit, onInputChange = () => {}, shou
const [hours, setHours] = useState(() => DateUtils.get12HourTimeObjectFromDate(value, showFullFormat).hour);
const [minutes, setMinutes] = useState(() => DateUtils.get12HourTimeObjectFromDate(value, showFullFormat).minute);
const [seconds, setSeconds] = useState(() => DateUtils.get12HourTimeObjectFromDate(value, showFullFormat).seconds);
const [miliseconds, setMiliseconds] = useState(() => DateUtils.get12HourTimeObjectFromDate(value, showFullFormat).miliseconds);
const [milliseconds, setMilliseconds] = useState(() => DateUtils.get12HourTimeObjectFromDate(value, showFullFormat).milliseconds);
const [amPmValue, setAmPmValue] = useState(() => DateUtils.get12HourTimeObjectFromDate(value, showFullFormat).period);

const lastPressedKey = useRef('');
Expand Down Expand Up @@ -189,7 +189,7 @@ function TimePicker({defaultValue = '', onSubmit, onInputChange = () => {}, shou
setSelectionSecond({start: 0, end: 0});
};

const resetMiliseconds = () => {
const resetMilliseconds = () => {
setMinutes('000');
setSelectionMilisecond({start: 0, end: 0});
};
Expand Down Expand Up @@ -440,14 +440,14 @@ function TimePicker({defaultValue = '', onSubmit, onInputChange = () => {}, shou
};

/*
This function receives value from the miliseconds input and validates it.
This function receives value from the milliseconds input and validates it.
The valid format is SSS(from 000 to 999). If the user enters 9, it will be prepended to 009. If the user tries to change 999 to 9999, it would skip the character
*/
const handleMilisecondsChange = (text: string) => {
const handleMillisecondsChange = (text: string) => {
// Replace spaces with 0 to implement the following digit removal by pressing space
const trimmedText = text.replace(/ /g, '0');
if (!trimmedText) {
resetMiliseconds();
resetMilliseconds();
return;
}

Expand All @@ -460,7 +460,7 @@ function TimePicker({defaultValue = '', onSubmit, onInputChange = () => {}, shou
let newSelection;

if (selectionMilisecond.start === 0 && selectionMilisecond.end === 0) {
// The cursor is at the start of miliseconds
// The cursor is at the start of milliseconds
const firstDigit = trimmedText[0];
const secondDigit = trimmedText[2] || '0';
const thirdDigit = trimmedText[3] || '0';
Expand Down Expand Up @@ -514,10 +514,10 @@ function TimePicker({defaultValue = '', onSubmit, onInputChange = () => {}, shou
}

if (Number(newMilisecond) > 999) {
newMilisecond = miliseconds;
newMilisecond = milliseconds;
}

setMiliseconds(newMilisecond);
setMilliseconds(newMilisecond);
setSelectionMilisecond({start: newSelection, end: newSelection});
};

Expand Down Expand Up @@ -563,7 +563,7 @@ function TimePicker({defaultValue = '', onSubmit, onInputChange = () => {}, shou
return;
}

clearSelectedValue(miliseconds, selectionMilisecond, setMiliseconds, setSelectionMilisecond, 3);
clearSelectedValue(milliseconds, selectionMilisecond, setMilliseconds, setSelectionMilisecond, 3);
}
return;
}
Expand All @@ -576,11 +576,11 @@ function TimePicker({defaultValue = '', onSubmit, onInputChange = () => {}, shou
} else if (isSecondFocused) {
handleSecondsChange(insertAtPosition(seconds, trimmedKey, selectionSecond.start, selectionSecond.end));
} else if (isMilisecondFocused) {
handleMilisecondsChange(insertAtPosition(miliseconds, trimmedKey, selectionMilisecond.start, selectionMilisecond.end));
handleMillisecondsChange(insertAtPosition(milliseconds, trimmedKey, selectionMilisecond.start, selectionMilisecond.end));
}
},
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
[minutes, hours, seconds, miliseconds, selectionMinute, selectionHour, selectionSecond, selectionMilisecond],
[minutes, hours, seconds, milliseconds, selectionMinute, selectionHour, selectionSecond, selectionMilisecond],
);

useEffect(() => {
Expand Down Expand Up @@ -690,12 +690,12 @@ function TimePicker({defaultValue = '', onSubmit, onInputChange = () => {}, shou
}, [canUseTouchScreen, updateAmountNumberPad]);

useEffect(() => {
onInputChange(showFullFormat ? `${hours}:${minutes}:${seconds}.${miliseconds} ${amPmValue}` : `${hours}:${minutes} ${amPmValue}`);
onInputChange(showFullFormat ? `${hours}:${minutes}:${seconds}.${milliseconds} ${amPmValue}` : `${hours}:${minutes} ${amPmValue}`);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [hours, minutes, amPmValue]);

const handleSubmit = () => {
const time = showFullFormat ? `${hours}:${minutes}:${seconds}.${miliseconds}` : `${hours}:${minutes} ${amPmValue}`;
const time = showFullFormat ? `${hours}:${minutes}:${seconds}.${milliseconds}` : `${hours}:${minutes} ${amPmValue}`;
const isValid = validate(time);

if (isValid) {
Expand Down Expand Up @@ -796,12 +796,12 @@ function TimePicker({defaultValue = '', onSubmit, onInputChange = () => {}, shou
<Text style={[styles.timePickerSemiDot, showFullFormat && [styles.textXXLarge, {height: undefined}]]}>{CONST.COLON}</Text>
<AmountTextInput
placeholder={numberFormat(0)}
formattedAmount={miliseconds}
formattedAmount={milliseconds}
onKeyPress={(e) => {
lastPressedKey.current = e.nativeEvent.key;
handleFocusOnBackspace(e);
}}
onChangeAmount={handleMilisecondsChange}
onChangeAmount={handleMillisecondsChange}
ref={(textInputRef) => {
updateRefs('milisecondRef', textInputRef);
milisecondInputRef.current = textInputRef as TextInput | null;
Expand Down
18 changes: 18 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4829,5 +4829,23 @@ export default {
date: 'Date',
time: 'Time',
none: 'None',
reasonVisibleInLHN: {
hasDraftComment: 'Has draft comment',
hasGBR: 'Has GBR',
pinnedByUser: 'Pinned by user',
isNonReimbursedIOU: 'Is non reimbursed IOU',
hasAddWorkspaceRoomErrors: 'Has add workspace room errors',
isUnread: 'Is unread (focus mode)',
isArchived: 'Is archived (most recent mode)',
isSelfDM: 'Is self DM',
isFocused: 'Is temporarily focused',
},
reasonGBR: {
hasJoinRequest: 'Has join request (admin room)',
isUnreadWithMention: 'Is unread with mention',
isWaitingForAssigneeToCompleteAction: 'Is waiting for assignee to complete action',
hasChildReportAwaitingAction: 'Has child report awaiting action',
hasMissingInvoiceBankAccount: 'Has missing invoice bank account',
},
},
} satisfies TranslationBase;
18 changes: 18 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5346,5 +5346,23 @@ export default {
date: 'Fecha',
time: 'Hora',
none: 'Ninguno',
reasonVisibleInLHN: {
hasDraftComment: 'Tiene comentario en borrador',
hasGBR: 'Tiene GBR',
pinnedByUser: 'Fijado por el usuario',
isNonReimbursedIOU: 'Es un IOU no reembolsado',
hasAddWorkspaceRoomErrors: 'Tiene errores al agregar sala de espacio de trabajo',
isUnread: 'No leído (modo de enfoque)',
isArchived: 'Archivado (modo más reciente)',
isSelfDM: 'Es un DM propio',
isFocused: 'Está temporalmente enfocado',
},
reasonGBR: {
hasJoinRequest: 'Tiene solicitud de unión (sala de administrador)',
isUnreadWithMention: 'No leído con mención',
isWaitingForAssigneeToCompleteAction: 'Esperando a que el asignado complete la acción',
hasChildReportAwaitingAction: 'Informe secundario pendiente de acción',
hasMissingInvoiceBankAccount: 'Falta la cuenta bancaria de la factura',
},
},
} satisfies EnglishTranslation;
8 changes: 4 additions & 4 deletions src/libs/DateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,15 +614,15 @@ const combineDateAndTime = (updatedTime: string, inputDateTime: string): string
/**
* param {String} dateTime in 'HH:mm:ss.SSS a' format
* returns {Object}
* example {hour: '11', minute: '10', seconds: '10', miliseconds: '123', period: 'AM'}
* example {hour: '11', minute: '10', seconds: '10', milliseconds: '123', period: 'AM'}
*/
function get12HourTimeObjectFromDate(dateTime: string, isFullFormat = false): {hour: string; minute: string; seconds: string; miliseconds: string; period: string} {
function get12HourTimeObjectFromDate(dateTime: string, isFullFormat = false): {hour: string; minute: string; seconds: string; milliseconds: string; period: string} {
if (!dateTime) {
return {
hour: '12',
minute: '00',
seconds: '00',
miliseconds: '000',
milliseconds: '000',
period: 'PM',
};
}
Expand All @@ -631,7 +631,7 @@ function get12HourTimeObjectFromDate(dateTime: string, isFullFormat = false): {h
hour: format(parsedTime, 'hh'),
minute: format(parsedTime, 'mm'),
seconds: isFullFormat ? format(parsedTime, 'ss') : '00',
miliseconds: isFullFormat ? format(parsedTime, 'SSS') : '000',
milliseconds: isFullFormat ? format(parsedTime, 'SSS') : '000',
period: format(parsedTime, 'a').toUpperCase(),
};
}
Expand Down
Loading
Loading