Skip to content

Commit

Permalink
show refresh button when failed to fetch meta
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Jan 3, 2024
1 parent 688dd8d commit 36475d5
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions lib/view/settings_page/tab_settings_page/tab_settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,6 @@ class TabSettingsAddDialogState extends ConsumerState<TabSettingsPage> {
};
}

@override
void initState() {
super.initState();
hostController.addListener(() {
if (host != hostController.text) {
setState(() {
host = hostController.text;
});
refresh();
}
});
}

@override
void didChangeDependencies() {
super.didChangeDependencies();
Expand Down Expand Up @@ -215,6 +202,7 @@ class TabSettingsAddDialogState extends ConsumerState<TabSettingsPage> {
refresh();
},
value: selectedAccount,
isExpanded: true,
),
if (selectedAccount == null) ...[
const Padding(padding: EdgeInsets.all(10)),
Expand All @@ -225,17 +213,29 @@ class TabSettingsAddDialogState extends ConsumerState<TabSettingsPage> {
prefixIcon: const Icon(Icons.dns),
suffixIcon: IconButton(
onPressed: () async {
final host = await showDialog<String?>(
final result = await showDialog<String?>(
context: context,
builder: (context) => const MisskeyServerListDialog(),
);
if (host != null && host.isNotEmpty) {
hostController.text = host;
if (result != null) {
setState(() {
hostController.text = result;
host = result;
});
refresh();
}
},
icon: const Icon(Icons.search),
),
),
onChanged: (result) {
if (result != host) {
setState(() {
host = result;
});
refresh();
}
},
),
],
const Padding(padding: EdgeInsets.all(10)),
Expand Down Expand Up @@ -272,9 +272,18 @@ class TabSettingsAddDialogState extends ConsumerState<TabSettingsPage> {
});
},
value: selectedTabType,
isExpanded: true,
);
} else {
} else if (snapshot.connectionState ==
ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
} else {
return Center(
child: IconButton(
onPressed: () => setState(() {}),
icon: const Icon(Icons.refresh),
),
);
}
},
),
Expand Down

0 comments on commit 36475d5

Please sign in to comment.