From 928941caf935f1fb7a41c3bc87cc4ca270f50663 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Tue, 17 Sep 2024 11:21:49 -0700 Subject: [PATCH 1/2] Show too many writes error whenever it's set in response data --- src/CONST.ts | 1 - src/libs/HttpUtils.ts | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 86cbd4c28fc9..313bcdf9fb70 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1151,7 +1151,6 @@ const CONST = { BAD_REQUEST: 400, NOT_AUTHENTICATED: 407, EXP_ERROR: 666, - MANY_WRITES_ERROR: 665, UNABLE_TO_RETRY: 'unableToRetry', UPDATE_REQUIRED: 426, }, diff --git a/src/libs/HttpUtils.ts b/src/libs/HttpUtils.ts index 550a75c3d361..09818528b046 100644 --- a/src/libs/HttpUtils.ts +++ b/src/libs/HttpUtils.ts @@ -130,15 +130,10 @@ function processHTTPRequest(url: string, method: RequestType = 'get', body: Form }); } - if (response.jsonCode === CONST.JSON_CODE.MANY_WRITES_ERROR) { - if (response.data) { - const {phpCommandName, authWriteCommands} = response.data; - // eslint-disable-next-line max-len - const message = `The API call (${phpCommandName}) did more Auth write requests than allowed. Count ${authWriteCommands.length}, commands: ${authWriteCommands.join( - ', ', - )}. Check the APIWriteCommands class in Web-Expensify`; - alert('Too many auth writes', message); - } + if (response.data && (response.data?.authWriteCommands?.length ?? 0)) { + const {phpCommandName, authWriteCommands} = response.data; + const message = `The API command ${phpCommandName} is doing too many Auth writes. Count ${authWriteCommands.length}, commands: ${authWriteCommands.join(', ')}. If you modified this command, you MUST refactor it to remove the extra Auth writes. Otherwise, update the allowed write count in Web-Expensify APIWriteCommands.`; + alert('Too many auth writes', message); } if (response.jsonCode === CONST.JSON_CODE.UPDATE_REQUIRED) { // Trigger a modal and disable the app as the user needs to upgrade to the latest minimum version to continue From 2a7b9957046b0352e25d7e33395381691f6226a4 Mon Sep 17 00:00:00 2001 From: neil-marcellini Date: Tue, 17 Sep 2024 11:49:57 -0700 Subject: [PATCH 2/2] Prettify --- src/libs/HttpUtils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/HttpUtils.ts b/src/libs/HttpUtils.ts index 09818528b046..de6aea96cb47 100644 --- a/src/libs/HttpUtils.ts +++ b/src/libs/HttpUtils.ts @@ -132,7 +132,9 @@ function processHTTPRequest(url: string, method: RequestType = 'get', body: Form if (response.data && (response.data?.authWriteCommands?.length ?? 0)) { const {phpCommandName, authWriteCommands} = response.data; - const message = `The API command ${phpCommandName} is doing too many Auth writes. Count ${authWriteCommands.length}, commands: ${authWriteCommands.join(', ')}. If you modified this command, you MUST refactor it to remove the extra Auth writes. Otherwise, update the allowed write count in Web-Expensify APIWriteCommands.`; + const message = `The API command ${phpCommandName} is doing too many Auth writes. Count ${authWriteCommands.length}, commands: ${authWriteCommands.join( + ', ', + )}. If you modified this command, you MUST refactor it to remove the extra Auth writes. Otherwise, update the allowed write count in Web-Expensify APIWriteCommands.`; alert('Too many auth writes', message); } if (response.jsonCode === CONST.JSON_CODE.UPDATE_REQUIRED) {