Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3be886e
feat: Combined optimistic report names functionality
sosek108 Aug 25, 2025
f39ed5e
fixes
sosek108 Aug 25, 2025
c85dfa8
formulatest reintroduction
sosek108 Aug 25, 2025
117a693
Merge branch 'main' into feat/combined-optimistic-report-names
sosek108 Aug 26, 2025
eddaf3b
formulatest reintroduction
sosek108 Aug 26, 2025
38ea7c7
Revert Mobile-Expensify submodule update from eddaf3be1b1f
sosek108 Aug 28, 2025
88bfd79
Merge branch 'main' into feat/combined-optimistic-report-names
sosek108 Aug 28, 2025
be49678
Changes to the implementation
sosek108 Aug 28, 2025
36279fe
Merge branch 'main' into feat/combined-optimistic-report-names
sosek108 Sep 1, 2025
ecdf717
Merge remote-tracking branch 'exfy/neil-explicit-betas' into feat/com…
sosek108 Sep 1, 2025
809a1ae
Introduce beta configuration into optimistic report name computation.
sosek108 Sep 1, 2025
7b3055f
Merge branch 'main' into feat/combined-optimistic-report-names
sosek108 Sep 2, 2025
6079f50
Merge branch 'main' into feat/combined-optimistic-report-names
sosek108 Sep 2, 2025
c359d70
Merge branch 'main' into feat/combined-optimistic-report-names
sosek108 Sep 5, 2025
a8c6324
Remove Timing / Performance from OptimisticReportNames entry point
sosek108 Sep 5, 2025
ecdf926
Merge branch 'main' into feat/combined-optimistic-report-names
sosek108 Sep 8, 2025
fd99275
Merge branch 'main' into feat/combined-optimistic-report-names
sosek108 Sep 9, 2025
1a97d27
Fixes according to code review
sosek108 Sep 9, 2025
efa8973
remove unintended changes
sosek108 Sep 9, 2025
4267e54
remove unintended changes
sosek108 Sep 9, 2025
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
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"formatjs",
"Français",
"Frederico",
"freetext",
"frontpart",
"fullstory",
"FWTV",
Expand Down
2 changes: 2 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,8 @@ const CONST = {
APPLY_AIRSHIP_UPDATES: 'apply_airship_updates',
APPLY_PUSHER_UPDATES: 'apply_pusher_updates',
APPLY_HTTPS_UPDATES: 'apply_https_updates',
COMPUTE_REPORT_NAME: 'compute_report_name',
COMPUTE_REPORT_NAME_FOR_NEW_REPORT: 'compute_report_name_for_new_report',
COLD: 'cold',
WARM: 'warm',
REPORT_ACTION_ITEM_LAYOUT_DEBOUNCE_TIME: 1500,
Expand Down
26 changes: 24 additions & 2 deletions src/libs/API/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Log from '@libs/Log';
import {handleDeletedAccount, HandleUnusedOptimisticID, Logging, Pagination, Reauthentication, RecheckConnection, SaveResponseInOnyx} from '@libs/Middleware';
import {isOffline} from '@libs/Network/NetworkStore';
import {push as pushToSequentialQueue, waitForIdle as waitForSequentialQueueIdle} from '@libs/Network/SequentialQueue';
import * as OptimisticReportNames from '@libs/OptimisticReportNames';
import {getUpdateContext, initialize as initializeOptimisticReportNamesContext} from '@libs/OptimisticReportNamesConnectionManager';
import Pusher from '@libs/Pusher';
import {processWithMiddleware, use} from '@libs/Request';
import {getAll, getLength as getPersistedRequestsLength} from '@userActions/PersistedRequests';
Expand All @@ -15,7 +17,7 @@ import type OnyxRequest from '@src/types/onyx/Request';
import type {PaginatedRequest, PaginationConfig, RequestConflictResolver} from '@src/types/onyx/Request';
import type Response from '@src/types/onyx/Response';
import type {ApiCommand, ApiRequestCommandParameters, ApiRequestType, CommandOfType, ReadCommand, SideEffectRequestCommand, WriteCommand} from './types';
import {READ_COMMANDS} from './types';
import {READ_COMMANDS, WRITE_COMMANDS} from './types';

// Setup API middlewares. Each request made will pass through a series of middleware functions that will get called in sequence (each one passing the result of the previous to the next).
// Note: The ordering here is intentional as we want to Log, Recheck Connection, Reauthenticate, and Save the Response in Onyx. Errors thrown in one middleware will bubble to the next.
Expand All @@ -42,6 +44,11 @@ use(Pagination);
// middlewares after this, because the SequentialQueue depends on the result of this middleware to pause the queue (if needed) to bring the app to an up-to-date state.
use(SaveResponseInOnyx);

// Initialize OptimisticReportNames context on module load
initializeOptimisticReportNamesContext().catch(() => {
Log.warn('Failed to initialize OptimisticReportNames context');
});

let requestIndex = 0;

type OnyxData = {
Expand Down Expand Up @@ -74,7 +81,22 @@ function prepareRequest<TCommand extends ApiCommand>(
const {optimisticData, ...onyxDataWithoutOptimisticData} = onyxData;
if (optimisticData && shouldApplyOptimisticData) {
Log.info('[API] Applying optimistic data', false, {command, type});
Onyx.update(optimisticData);

// Process optimistic data through report name middleware
// Skip for OpenReport command to avoid unnecessary processing
if (command === WRITE_COMMANDS.OPEN_REPORT) {
Onyx.update(optimisticData);
} else {
try {
const context = getUpdateContext();
const processedOptimisticData = OptimisticReportNames.updateOptimisticReportNamesFromUpdates(optimisticData, context);
Onyx.update(processedOptimisticData);
} catch (error) {
Log.hmmm('[API] Failed to process optimistic report names', {error});
// Fallback to original optimistic data if processing fails
Onyx.update(optimisticData);
}
}
}

const isWriteRequest = type === CONST.API_REQUEST_TYPE.WRITE;
Expand Down
Loading
Loading