Reset requestTabIndex on request type change

This commit is contained in:
Ankit Mahato
2025-12-04 23:06:07 +05:30
parent 5af87725eb
commit 8f029e134e
3 changed files with 6 additions and 11 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,