Skip to content
Draft
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
457 changes: 197 additions & 260 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@
"react-native-nitro-fetch": "1.6.2",
"react-native-nitro-image": "0.15.2",
"react-native-nitro-modules": "0.37.1",
"react-native-nitro-sqlite": "9.8.3",
"react-native-onyx": "3.0.119",
"react-native-nitro-sqlite": "10.2.0",
"react-native-onyx": "3.0.133",
"react-native-pager-view": "9.0.4",
"react-native-pdf": "7.0.2",
"react-native-permissions": "^5.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function MultifactorAuthenticationContextProvider({children}: MultifactorAuthent
deviceBiometricsState = data;
},
});
return () => Onyx.disconnect(connection);
return () => connection.unsubscribe();
}, [accountID]);

const startStateRef = useRef<CredentialsState | undefined>(undefined);
Expand Down
8 changes: 4 additions & 4 deletions src/libs/ConciergeResponseIndicator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,10 @@ function subscribeToReport(responseReportActionID: string, reportID: string) {
},
});
if (reportSubscriptions.get(reportID) !== reportSubscription) {
Onyx.disconnect(reportConnection);
reportConnection.unsubscribe();
return;
}
reportSubscription.cleanups.push(() => Onyx.disconnect(reportConnection));
reportSubscription.cleanups.push(() => reportConnection.unsubscribe());

// Watch only the question/response reports while a request is tracked. This non-render
// subscription detects failed sends and reconciles durable replies after missed events.
Expand All @@ -329,10 +329,10 @@ function subscribeToReport(responseReportActionID: string, reportID: string) {
});
// The initial callback can finish the last request before connectWithoutView returns.
if (reportSubscriptions.get(reportID) !== reportSubscription) {
Onyx.disconnect(connection);
connection.unsubscribe();
return;
}
reportSubscription.cleanups.push(() => Onyx.disconnect(connection));
reportSubscription.cleanups.push(() => connection.unsubscribe());
}

/** Register a local or peer request without broadcasting it back to other tabs. */
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Network/SequentialQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ function flush(shouldResetPromise = true) {
requestsLength: getAllPersistedRequests().length,
ongoingCommand: getPersistedOngoingRequest()?.command ?? 'null',
});
Onyx.disconnect(connection);
connection.unsubscribe();
process().finally(() => {
const remainingPersistedRequests = getAllPersistedRequests().length;
const hasOngoingRequest = !!getPersistedOngoingRequest();
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Device/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getDeviceID(): Promise<string | null> {
const connection = Onyx.connectWithoutView({
key: ONYXKEYS.DEVICE_ID,
callback: (id) => {
Onyx.disconnect(connection);
connection.unsubscribe();
deviceID = id ?? null;
return resolve(id ?? null);
},
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function clearStaleExportDownloads() {
const connectionID = Onyx.connectWithoutView({
key: ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD,
callback: (exportDownloads) => {
Onyx.disconnect(connectionID);
connectionID.unsubscribe();
if (!exportDownloads) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/ImportSpreadsheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function waitForImportFinalModal(importFinalModalID: string): ImportFinalModalRe
}

isPending = false;
Onyx.disconnect(connection);
connection.unsubscribe();
resolve(spreadsheet.importFinalModal);
},
});
Expand All @@ -134,7 +134,7 @@ function waitForImportFinalModal(importFinalModalID: string): ImportFinalModalRe
}

isPending = false;
Onyx.disconnect(connection);
connection.unsubscribe();
},
};
}
Expand Down
6 changes: 3 additions & 3 deletions src/libs/actions/Link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ function openReportFromDeepLink(
const handleDeeplinkNavigation = () => {
// We want to disconnect the connection so it won't trigger the deeplink again
// every time the data is changed, for example, when re-login.
Onyx.disconnect(connection);
connection.unsubscribe();

const state = navigationRef.getRootState();
const currentFocusedRoute = findFocusedRoute(state);
Expand Down Expand Up @@ -615,7 +615,7 @@ function openReportFromDeepLink(
if (!report?.errorFields?.notFound && !report?.reportID && !(report === undefined && CONST.REGEX.NON_NUMERIC.test(reportID))) {
return;
}
Onyx.disconnect(reportConnection);
reportConnection.unsubscribe();
navigateHandler(report);
},
});
Expand Down Expand Up @@ -646,7 +646,7 @@ function openReportFromDeepLink(
if (isLoadingReportData) {
return;
}
Onyx.disconnect(loadingConnection);
loadingConnection.unsubscribe();

// The concierge route is a URL entry page that redirects itself, and on wide layouts it slides in as a
// panel first, so open the chat the way the rest of the app does instead.
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/MapboxToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const init = () => {
const stop = () => {
console.debug('[MapboxToken] Stopping all listeners and timers');
if (tokenConnection) {
Onyx.disconnect(tokenConnection);
tokenConnection.unsubscribe();
tokenConnection = null;
}
if (unsubscribeReachability) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/OnyxDerived/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function init() {
const connection = Onyx.connectWithoutView({
key,
callback: (storedDerivedValue) => {
Onyx.disconnect(connection);
connection.unsubscribe();
resolve(storedDerivedValue);
},
});
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Report/DeferredAttachmentEdits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ function watchDeferredAttachmentEdit(reportActionID: string, deferredEdit: Defer
hasStopped = true;
deferredAttachmentEditWatchers.delete(reportActionID);
for (const connection of connections.splice(0)) {
Onyx.disconnect(connection);
connection.unsubscribe();
}
};
// A subscriber can fire while it is still being connected, so a connection made after the watcher stopped is
// disconnected rather than stored.
const track = (connection: Connection) => {
if (hasStopped) {
Onyx.disconnect(connection);
connection.unsubscribe();
return;
}
connections.push(connection);
Expand Down
8 changes: 4 additions & 4 deletions src/libs/actions/Report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,7 @@ function navigateToAndOpenReport({
callback: (updatedReport) => {
const notFoundError = updatedReport?.errorFields?.notFound;
if (notFoundError === null) {
Onyx.disconnect(reportConnection);
reportConnection.unsubscribe();
return;
}

Expand All @@ -2781,7 +2781,7 @@ function navigateToAndOpenReport({
}

hasAttemptedFallback = true;
Onyx.disconnect(reportConnection);
reportConnection.unsubscribe();
createAndOpenNewOptimisticChat(chat.reportID);
},
});
Expand Down Expand Up @@ -2938,7 +2938,7 @@ function navigateToAndOpenReportWithAccountIDs(
callback: (updatedReport) => {
const notFoundError = updatedReport?.errorFields?.notFound;
if (notFoundError === null) {
Onyx.disconnect(reportConnection);
reportConnection.unsubscribe();
return;
}

Expand All @@ -2947,7 +2947,7 @@ function navigateToAndOpenReportWithAccountIDs(
}

hasAttemptedFallback = true;
Onyx.disconnect(reportConnection);
reportConnection.unsubscribe();
createAndOpenNewOptimisticChat(chat.reportID);
},
});
Expand Down
16 changes: 8 additions & 8 deletions src/libs/actions/TransactionEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Onyx from 'react-native-onyx';

import {generateTransactionID} from './Transaction';

let connection: Connection;
let connection: Connection | undefined;

/**
* Makes a backup copy of a transaction object that can be restored when the user cancels editing a transaction.
Expand All @@ -24,7 +24,7 @@ function createBackupTransaction(transaction: OnyxEntry<Transaction>, isDraft: b
// In Strict Mode, the backup logic useEffect is triggered twice on mount. The restore logic is delayed because we need to connect to the onyx first,
// so it's possible that the restore logic is executed after creating the backup for the 2nd time which will completely clear the backup.
// To avoid that, we need to cancel the pending connection.
Onyx.disconnect(connection);
connection?.unsubscribe();
const newTransaction = {
...transaction,
};
Expand All @@ -41,7 +41,7 @@ function createBackupTransaction(transaction: OnyxEntry<Transaction>, isDraft: b
const conn = Onyx.connectWithoutView({
key: `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transaction.transactionID}`,
callback: (transactionBackup) => {
Onyx.disconnect(conn);
conn.unsubscribe();
// Treat a backup missing `transactionID` as corrupted (a partial route-fetch shape can
// leak in via Pusher) and overwrite it instead of restoring from it.
if (transactionBackup?.transactionID) {
Expand Down Expand Up @@ -76,7 +76,7 @@ function restoreOriginalTransactionFromBackup(transactionID: string | undefined,
connection = Onyx.connectWithoutView({
key: `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`,
callback: (backupTransaction) => {
Onyx.disconnect(connection);
connection?.unsubscribe();

// Use set to completely overwrite the original transaction
Onyx.set(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, backupTransaction ?? null);
Expand Down Expand Up @@ -197,11 +197,11 @@ function removeBackupTransactionWithImageCleanup(transactionID: string | undefin
const backupConn = Onyx.connectWithoutView({
key: `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`,
callback: (backupTransaction) => {
Onyx.disconnect(backupConn);
backupConn.unsubscribe();
const currentConn = Onyx.connectWithoutView({
key: `${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
callback: (currentTransaction) => {
Onyx.disconnect(currentConn);
currentConn.unsubscribe();
revokeOdometerImageUri(backupTransaction?.comment?.odometerStartImage, currentTransaction?.comment?.odometerStartImage);
revokeOdometerImageUri(backupTransaction?.comment?.odometerEndImage, currentTransaction?.comment?.odometerEndImage);
removeBackupTransaction(transactionID);
Expand All @@ -220,11 +220,11 @@ function restoreOriginalTransactionFromBackupWithImageCleanup(transactionID: str
connection = Onyx.connectWithoutView({
key: `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`,
callback: (backupTransaction) => {
Onyx.disconnect(connection);
connection?.unsubscribe();
const currentConn = Onyx.connectWithoutView({
key: `${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
callback: (currentTransaction) => {
Onyx.disconnect(currentConn);
currentConn.unsubscribe();
revokeOdometerImageUri(currentTransaction?.comment?.odometerStartImage, backupTransaction?.comment?.odometerStartImage);
revokeOdometerImageUri(currentTransaction?.comment?.odometerEndImage, backupTransaction?.comment?.odometerEndImage);
Onyx.set(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, backupTransaction ?? null)
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ const isChannelMuted = (reportId: string, currentUserAccountID: number) =>
const connection = Onyx.connectWithoutView({
key: `${ONYXKEYS.COLLECTION.REPORT}${reportId}`,
callback: (report) => {
Onyx.disconnect(connection);
connection.unsubscribe();
const notificationPreference = report?.participants?.[currentUserAccountID]?.notificationPreference;

resolve(!notificationPreference || notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.MUTE || ReportUtils.isHiddenForCurrentUser(notificationPreference));
Expand Down
4 changes: 2 additions & 2 deletions src/libs/cleanupPreMountedDraftReports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function cleanupReportDrafts(markers: OnyxCollection<boolean>) {
let reportDraftsConnection: ReturnType<typeof Onyx.connectWithoutView>;

function handleReportDrafts(reportDrafts: OnyxCollection<Report>) {
Onyx.disconnect(reportDraftsConnection);
reportDraftsConnection.unsubscribe();
Onyx.multiSet(getPreMountedDraftReportCleanupData(markers, reportDrafts));
}

Expand All @@ -60,7 +60,7 @@ function cleanupPreMountedDraftReports() {
let markersConnection: ReturnType<typeof Onyx.connectWithoutView>;

function handleMarkers(markers: OnyxCollection<boolean>) {
Onyx.disconnect(markersConnection);
markersConnection.unsubscribe();
if (!Object.keys(markers ?? {}).length) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/migrations/MoveFilesOutOfDocuments/index.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function updateAttachmentRecordPaths(): Promise<void> {
const connection = Onyx.connectWithoutView({
key: ONYXKEYS.ATTACHMENT_RECORD_PATHS_MIGRATED,
callback: (hasMigrated) => {
Onyx.disconnect(connection);
connection.unsubscribe();
resolve(hasMigrated);
},
});
Expand All @@ -81,7 +81,7 @@ function updateAttachmentRecordPaths(): Promise<void> {
const connection = Onyx.connectWithoutView({
key: ONYXKEYS.COLLECTION.ATTACHMENT,
callback: (attachments: OnyxCollection<Attachment>) => {
Onyx.disconnect(connection);
connection.unsubscribe();

const updates: Record<string, Attachment> = {};
for (const [key, attachment] of Object.entries(attachments ?? {})) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/migrations/RenameLegacySageIntacctExportDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function RenameLegacySageIntacctExportDate(): Promise<void> {
const connection = Onyx.connectWithoutView({
key: ONYXKEYS.COLLECTION.POLICY,
callback: (policies: OnyxCollection<Policy>) => {
Onyx.disconnect(connection);
connection.unsubscribe();

const updates: OnyxMergeCollectionInput<typeof ONYXKEYS.COLLECTION.POLICY> = {};
for (const policy of Object.values(policies ?? {})) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/readOnceOnyxValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function readOnceOnyxValue<TKey extends OnyxKey>(key: TKey): Promise<OnyxValue<T
const connection = Onyx.connectWithoutView({
key,
callback: (value) => {
Onyx.disconnect(connection);
connection.unsubscribe();
resolve(value);
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/libs/subscribeToFullReconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Onyx.connectWithoutView({
const connection = Onyx.connectWithoutView({
key: ONYXKEYS.LAST_FULL_RECONNECT_TIME,
callback: (lastFullReconnectTimeOnyxValue) => {
Onyx.disconnect(connection);
connection.unsubscribe();
lastFullReconnectTime = lastFullReconnectTimeOnyxValue ?? '';
doFullReconnectIfNecessary();
},
Expand Down
2 changes: 1 addition & 1 deletion src/libs/telemetry/crashDiagnostics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ function cleanupCrashDiagnostics() {
livenessChannel = undefined;
}
if (reportsConnection) {
Onyx.disconnect(reportsConnection);
reportsConnection.unsubscribe();
reportsConnection = undefined;
}
if (typeof window !== 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion src/setup/backgroundLocationTrackingTask/index.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getGpsDraftDetails(): Promise<OnyxEntry<GpsDraftDetails>> {
const connection = Onyx.connectWithoutView({
key: ONYXKEYS.GPS_DRAFT_DETAILS,
callback: (gpsDraftDetails: OnyxEntry<GpsDraftDetails>) => {
Onyx.disconnect(connection);
connection.unsubscribe();
resolve(gpsDraftDetails);
},
});
Expand Down
4 changes: 2 additions & 2 deletions tests/actions/AttachmentTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('AttachmentStorage', () => {
const connection = Onyx.connect({
key: ONYXKEYS.COLLECTION.ATTACHMENT,
callback: (value) => {
Onyx.disconnect(connection);
connection.unsubscribe();
resolve(value);
},
});
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('AttachmentStorage', () => {
const connection = Onyx.connect({
key: ONYXKEYS.COLLECTION.ATTACHMENT,
callback: (value) => {
Onyx.disconnect(connection);
connection.unsubscribe();
resolve(value);
},
});
Expand Down
2 changes: 1 addition & 1 deletion tests/actions/BetaOverridesTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function getBetaOverrides(): Promise<BetaOverrides | undefined> {
const connection = Onyx.connect({
key: ONYXKEYS.BETA_OVERRIDES,
callback: (value) => {
Onyx.disconnect(connection);
connection.unsubscribe();
resolve(value);
},
});
Expand Down
Loading
Loading