mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-21 21:47:29 +01:00
Add a failsafe for extraData searches
This commit is contained in:
parent
eaa5510942
commit
76061a42f1
@ -32,6 +32,7 @@ class SearchResultCard extends StatefulWidget {
|
|||||||
|
|
||||||
class _SearchResultCardState extends State<SearchResultCard> {
|
class _SearchResultCardState extends State<SearchResultCard> {
|
||||||
PhrasePageScrapeResultData? extraData;
|
PhrasePageScrapeResultData? extraData;
|
||||||
|
bool? extraDataSearchFailed;
|
||||||
|
|
||||||
Future<PhrasePageScrapeResult?> _scrape(JishoResult result) =>
|
Future<PhrasePageScrapeResult?> _scrape(JishoResult result) =>
|
||||||
(!(result.japanese[0].word == null && result.japanese[0].reading == null))
|
(!(result.japanese[0].word == null && result.japanese[0].reading == null))
|
||||||
@ -133,18 +134,19 @@ class _SearchResultCardState extends State<SearchResultCard> {
|
|||||||
if (extensiveSearchEnabled && extraData == null) {
|
if (extensiveSearchEnabled && extraData == null) {
|
||||||
final data = await _scrape(widget.result);
|
final data = await _scrape(widget.result);
|
||||||
setState(() {
|
setState(() {
|
||||||
extraData = (data != null && data.found) ? data.data : null;
|
extraDataSearchFailed = !(data?.found ?? false);
|
||||||
|
extraData = !extraDataSearchFailed! ? data!.data : null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
title: _header,
|
title: _header,
|
||||||
children: [
|
children: [
|
||||||
if (extensiveSearchEnabled && extraData == null)
|
if (extensiveSearchEnabled && extraDataSearchFailed == null)
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 10),
|
padding: EdgeInsets.symmetric(vertical: 10),
|
||||||
child: Center(child: CircularProgressIndicator()),
|
child: Center(child: CircularProgressIndicator()),
|
||||||
)
|
)
|
||||||
else if (extraData != null)
|
else if (!extraDataSearchFailed!)
|
||||||
_body(extendedData: extraData)
|
_body(extendedData: extraData)
|
||||||
else
|
else
|
||||||
_body()
|
_body()
|
||||||
|
Loading…
Reference in New Issue
Block a user