From 737aac96ec9d843ca6784355a0b16a0fe1c7392d Mon Sep 17 00:00:00 2001 From: Udhay-Adithya Date: Tue, 1 Jul 2025 20:03:22 +0530 Subject: [PATCH] fix: keep ui state consistent with the original request model when scripts are run --- lib/providers/collection_providers.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/providers/collection_providers.dart b/lib/providers/collection_providers.dart index 1bb9fba2..af87e9f4 100644 --- a/lib/providers/collection_providers.dart +++ b/lib/providers/collection_providers.dart @@ -281,9 +281,10 @@ class CollectionStateNotifier return; } - if (requestModel != null && - !requestModel.preRequestScript.isNullOrEmpty()) { - requestModel = await handlePreRequestScript( + RequestModel executionRequestModel = requestModel!; + + if (!requestModel.preRequestScript.isNullOrEmpty()) { + executionRequestModel = await handlePreRequestScript( requestModel, originalEnvironmentModel, (envModel, updatedValues) { @@ -298,9 +299,9 @@ class CollectionStateNotifier ); } - APIType apiType = requestModel!.apiType; + APIType apiType = executionRequestModel.apiType; HttpRequestModel substitutedHttpRequestModel = - getSubstitutedHttpRequestModel(requestModel.httpRequestModel!); + getSubstitutedHttpRequestModel(executionRequestModel.httpRequestModel!); // set current model's isWorking to true and update state var map = {...state!};