Skip to content

Commit

Permalink
fix lint changed
Browse files Browse the repository at this point in the history
  • Loading branch information
TMisiukiewicz committed Dec 20, 2024
1 parent 1e68871 commit 05e49db
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
6 changes: 5 additions & 1 deletion src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,11 @@ function getMostRecentReportActionLastModified(): string {
/**
* @returns The report preview action or `null` if one couldn't be found
*/
function getReportPreviewAction(chatReportID: string, iouReportID: string): OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW>> {
function getReportPreviewAction(chatReportID: string | undefined, iouReportID: string | undefined): OnyxEntry<ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW>> {
if (!chatReportID || !iouReportID) {
return;
}

return Object.values(allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReportID}`] ?? {}).find(
(reportAction): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW> =>
reportAction && isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) && getOriginalMessage(reportAction)?.linkedReportID === iouReportID,
Expand Down
12 changes: 10 additions & 2 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,11 @@ function navigateToAndOpenChildReport(childReportID = '-1', parentReportAction:
* Gets the older actions that have not been read yet.
* Normally happens when you scroll up on a chat, and the actions have not been read yet.
*/
function getOlderActions(reportID: string, reportActionID: string) {
function getOlderActions(reportID: string | undefined, reportActionID: string | undefined) {
if (!reportID || !reportActionID) {
return;
}

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -1262,7 +1266,11 @@ function getOlderActions(reportID: string, reportActionID: string) {
* Gets the newer actions that have not been read yet.
* Normally happens when you are not located at the bottom of the list and scroll down on a chat.
*/
function getNewerActions(reportID: string, reportActionID: string) {
function getNewerActions(reportID: string | undefined, reportActionID: string | undefined) {
if (!reportID || !reportActionID) {
return;
}

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down
22 changes: 13 additions & 9 deletions src/pages/home/report/ReportActionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ function ReportActionsView({
const reactionListRef = useContext(ReactionListContext);
const route = useRoute<PlatformStackRouteProp<AuthScreensParamList, typeof SCREENS.REPORT>>();
const [session] = useOnyx(ONYXKEYS.SESSION);
const [transactionThreadReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID ?? -1}`, {
const [transactionThreadReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID ?? CONST.DEFAULT_NUMBER_ID}`, {
selector: (reportActions: OnyxEntry<OnyxTypes.ReportActions>) =>
ReportActionsUtils.getSortedReportActionsForDisplay(reportActions, ReportUtils.canUserPerformWriteAction(report), true),
});
const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID ?? -1}`);
const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID ?? CONST.DEFAULT_NUMBER_ID}`);
const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report.reportID}`);
const prevTransactionThreadReport = usePrevious(transactionThreadReport);
const reportActionID = route?.params?.reportActionID;
Expand Down Expand Up @@ -168,7 +168,7 @@ function ReportActionsView({
actions.push(optimisticCreatedAction);
}

const reportPreviewAction = ReportActionsUtils.getReportPreviewAction(report.chatReportID ?? '', report.reportID);
const reportPreviewAction = ReportActionsUtils.getReportPreviewAction(report.chatReportID, report.reportID);
const moneyRequestActions = allReportActions.filter((action) => {
const originalMessage = ReportActionsUtils.isMoneyRequestAction(action) ? ReportActionsUtils.getOriginalMessage(action) : undefined;
return (
Expand Down Expand Up @@ -284,11 +284,11 @@ function ReportActionsView({
if (!isEmptyObject(transactionThreadReport)) {
// Get newer actions based on the newest reportAction for the current report
const newestActionCurrentReport = reportActionIDMap.find((item) => item.reportID === reportID);
Report.getNewerActions(newestActionCurrentReport?.reportID ?? '-1', newestActionCurrentReport?.reportActionID ?? '-1');
Report.getNewerActions(newestActionCurrentReport?.reportID, newestActionCurrentReport?.reportActionID);

// Get newer actions based on the newest reportAction for the transaction thread report
const newestActionTransactionThreadReport = reportActionIDMap.find((item) => item.reportID === transactionThreadReport.reportID);
Report.getNewerActions(newestActionTransactionThreadReport?.reportID ?? '-1', newestActionTransactionThreadReport?.reportActionID ?? '-1');
Report.getNewerActions(newestActionTransactionThreadReport?.reportID, newestActionTransactionThreadReport?.reportActionID);
} else {
Report.getNewerActions(reportID, newestReportAction.reportActionID);
}
Expand Down Expand Up @@ -330,7 +330,11 @@ function ReportActionsView({
}, []);

const handleReportActionPagination = useCallback(
({firstReportActionID}: {firstReportActionID: string}) => {
({firstReportActionID}: {firstReportActionID: string | undefined}) => {
if (!firstReportActionID) {
return;
}

// This function is a placeholder as the actual pagination is handled by visibleReportActions
if (!hasMoreCached && !hasNewestReportAction) {
isFirstLinkedActionRender.current = false;
Expand Down Expand Up @@ -374,11 +378,11 @@ function ReportActionsView({
if (!isEmptyObject(transactionThreadReport)) {
// Get older actions based on the oldest reportAction for the current report
const oldestActionCurrentReport = reportActionIDMap.findLast((item) => item.reportID === reportID);
Report.getOlderActions(oldestActionCurrentReport?.reportID ?? '-1', oldestActionCurrentReport?.reportActionID ?? '-1');
Report.getOlderActions(oldestActionCurrentReport?.reportID, oldestActionCurrentReport?.reportActionID);

// Get older actions based on the oldest reportAction for the transaction thread report
const oldestActionTransactionThreadReport = reportActionIDMap.findLast((item) => item.reportID === transactionThreadReport.reportID);
Report.getOlderActions(oldestActionTransactionThreadReport?.reportID ?? '-1', oldestActionTransactionThreadReport?.reportActionID ?? '-1');
Report.getOlderActions(oldestActionTransactionThreadReport?.reportID, oldestActionTransactionThreadReport?.reportActionID);
} else {
// Retrieve the next REPORT.ACTIONS.LIMIT sized page of comments
Report.getOlderActions(reportID, oldestReportAction.reportActionID);
Expand Down Expand Up @@ -416,7 +420,7 @@ function ReportActionsView({
didLoadNewerChats.current = true;

if ((reportActionID && indexOfLinkedAction > -1) || !reportActionID) {
handleReportActionPagination({firstReportActionID: newestReportAction?.reportActionID ?? '-1'});
handleReportActionPagination({firstReportActionID: newestReportAction?.reportActionID});
}
},
[
Expand Down

0 comments on commit 05e49db

Please sign in to comment.