From 8f029e134e67c9e70ffddfbd35de998df7071662 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Thu, 4 Dec 2025 23:06:07 +0530 Subject: [PATCH] Reset requestTabIndex on request type change --- lib/providers/collection_providers.dart | 5 ++++- .../request_pane/ai_request/request_pane_ai.dart | 6 +----- .../details_card/request_pane/request_pane_graphql.dart | 6 +----- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/providers/collection_providers.dart b/lib/providers/collection_providers.dart index 12c19eeb..68c45cfd 100644 --- a/lib/providers/collection_providers.dart +++ b/lib/providers/collection_providers.dart @@ -250,12 +250,15 @@ class CollectionStateNotifier newModel = switch (apiType) { APIType.rest || APIType.graphql => currentModel.copyWith( apiType: apiType, + requestTabIndex: 0, name: name ?? currentModel.name, description: description ?? currentModel.description, httpRequestModel: const HttpRequestModel(), - aiRequestModel: null), + aiRequestModel: null, + ), APIType.ai => currentModel.copyWith( apiType: apiType, + requestTabIndex: 0, name: name ?? currentModel.name, description: description ?? currentModel.description, httpRequestModel: null, diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/ai_request/request_pane_ai.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/ai_request/request_pane_ai.dart index 4bf39d23..29dffd06 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/ai_request/request_pane_ai.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/ai_request/request_pane_ai.dart @@ -13,12 +13,8 @@ class EditAIRequestPane extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final selectedId = ref.watch(selectedIdStateProvider); final codePaneVisible = ref.watch(codePaneVisibleStateProvider); - var tabIndex = ref.watch( + final tabIndex = ref.watch( selectedRequestModelProvider.select((value) => value?.requestTabIndex)); - - if (tabIndex >= 3) { - tabIndex = 0; - } return RequestPane( selectedId: selectedId, diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_pane_graphql.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_pane_graphql.dart index ab751de5..65fd7956 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_pane_graphql.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_pane_graphql.dart @@ -15,7 +15,7 @@ class EditGraphQLRequestPane extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final selectedId = ref.watch(selectedIdStateProvider); - var tabIndex = ref.watch( + final tabIndex = ref.watch( selectedRequestModelProvider.select((value) => value?.requestTabIndex)); final codePaneVisible = ref.watch(codePaneVisibleStateProvider); final headerLength = ref.watch(selectedRequestModelProvider @@ -34,10 +34,6 @@ class EditGraphQLRequestPane extends ConsumerWidget { final hasAuth = ref.watch(selectedRequestModelProvider.select((value) => value?.httpRequestModel?.authModel?.type != APIAuthType.none)); - if (tabIndex >= 4) { - tabIndex = 0; - } - return RequestPane( selectedId: selectedId, codePaneVisible: codePaneVisible,