mirror of
https://github.com/foss42/apidash.git
synced 2025-12-07 21:50:34 +08:00
Reset requestTabIndex on request type change
This commit is contained in:
@@ -250,12 +250,15 @@ class CollectionStateNotifier
|
|||||||
newModel = switch (apiType) {
|
newModel = switch (apiType) {
|
||||||
APIType.rest || APIType.graphql => currentModel.copyWith(
|
APIType.rest || APIType.graphql => currentModel.copyWith(
|
||||||
apiType: apiType,
|
apiType: apiType,
|
||||||
|
requestTabIndex: 0,
|
||||||
name: name ?? currentModel.name,
|
name: name ?? currentModel.name,
|
||||||
description: description ?? currentModel.description,
|
description: description ?? currentModel.description,
|
||||||
httpRequestModel: const HttpRequestModel(),
|
httpRequestModel: const HttpRequestModel(),
|
||||||
aiRequestModel: null),
|
aiRequestModel: null,
|
||||||
|
),
|
||||||
APIType.ai => currentModel.copyWith(
|
APIType.ai => currentModel.copyWith(
|
||||||
apiType: apiType,
|
apiType: apiType,
|
||||||
|
requestTabIndex: 0,
|
||||||
name: name ?? currentModel.name,
|
name: name ?? currentModel.name,
|
||||||
description: description ?? currentModel.description,
|
description: description ?? currentModel.description,
|
||||||
httpRequestModel: null,
|
httpRequestModel: null,
|
||||||
|
|||||||
@@ -13,12 +13,8 @@ class EditAIRequestPane extends ConsumerWidget {
|
|||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final selectedId = ref.watch(selectedIdStateProvider);
|
final selectedId = ref.watch(selectedIdStateProvider);
|
||||||
final codePaneVisible = ref.watch(codePaneVisibleStateProvider);
|
final codePaneVisible = ref.watch(codePaneVisibleStateProvider);
|
||||||
var tabIndex = ref.watch(
|
final tabIndex = ref.watch(
|
||||||
selectedRequestModelProvider.select((value) => value?.requestTabIndex));
|
selectedRequestModelProvider.select((value) => value?.requestTabIndex));
|
||||||
|
|
||||||
if (tabIndex >= 3) {
|
|
||||||
tabIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RequestPane(
|
return RequestPane(
|
||||||
selectedId: selectedId,
|
selectedId: selectedId,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class EditGraphQLRequestPane extends ConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final selectedId = ref.watch(selectedIdStateProvider);
|
final selectedId = ref.watch(selectedIdStateProvider);
|
||||||
var tabIndex = ref.watch(
|
final tabIndex = ref.watch(
|
||||||
selectedRequestModelProvider.select((value) => value?.requestTabIndex));
|
selectedRequestModelProvider.select((value) => value?.requestTabIndex));
|
||||||
final codePaneVisible = ref.watch(codePaneVisibleStateProvider);
|
final codePaneVisible = ref.watch(codePaneVisibleStateProvider);
|
||||||
final headerLength = ref.watch(selectedRequestModelProvider
|
final headerLength = ref.watch(selectedRequestModelProvider
|
||||||
@@ -34,10 +34,6 @@ class EditGraphQLRequestPane extends ConsumerWidget {
|
|||||||
final hasAuth = ref.watch(selectedRequestModelProvider.select((value) =>
|
final hasAuth = ref.watch(selectedRequestModelProvider.select((value) =>
|
||||||
value?.httpRequestModel?.authModel?.type != APIAuthType.none));
|
value?.httpRequestModel?.authModel?.type != APIAuthType.none));
|
||||||
|
|
||||||
if (tabIndex >= 4) {
|
|
||||||
tabIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RequestPane(
|
return RequestPane(
|
||||||
selectedId: selectedId,
|
selectedId: selectedId,
|
||||||
codePaneVisible: codePaneVisible,
|
codePaneVisible: codePaneVisible,
|
||||||
|
|||||||
Reference in New Issue
Block a user