Skip to content
Merged
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
1 change: 0 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@
"formatjs",
"Français",
"Frederico",
"freetext",
"frontpart",
"fullstory",
"FWTV",
Expand Down
4 changes: 0 additions & 4 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ const CONST = {
BETAS: {
ALL: 'all',
ASAP_SUBMIT: 'asapSubmit',
AUTH_AUTO_REPORT_TITLE: 'authAutoReportTitle',
DEFAULT_ROOMS: 'defaultRooms',
P2P_DISTANCE_REQUESTS: 'p2pDistanceRequests',
SPOTNANA_TRAVEL: 'spotnanaTravel',
Expand Down Expand Up @@ -1528,9 +1527,6 @@ 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',
UPDATE_OPTIMISTIC_REPORT_NAMES: 'update_optimistic_report_names',
COLD: 'cold',
WARM: 'warm',
REPORT_ACTION_ITEM_LAYOUT_DEBOUNCE_TIME: 1500,
Expand Down
26 changes: 2 additions & 24 deletions src/libs/API/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ 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 @@ -17,7 +15,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, WRITE_COMMANDS} from './types';
import {READ_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 @@ -44,11 +42,6 @@ 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 @@ -81,22 +74,7 @@ function prepareRequest<TCommand extends ApiCommand>(
const {optimisticData, ...onyxDataWithoutOptimisticData} = onyxData;
if (optimisticData && shouldApplyOptimisticData) {
Log.info('[API] Applying optimistic data', false, {command, type});

// 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.warn('[API] Failed to process optimistic report names', {error});
// Fallback to original optimistic data if processing fails
Onyx.update(optimisticData);
}
}
Onyx.update(optimisticData);
}

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