fix search ui issues
This commit is contained in:
@@ -147,7 +147,7 @@ class _Header extends ConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
// A single record select rebuilds this header only when the session state
|
// A single record select rebuilds this header only when the session state
|
||||||
// or the number of ready artifacts for *this* result changes.
|
// or the artifacts for *this* result change.
|
||||||
final fetch = ref.watch(
|
final fetch = ref.watch(
|
||||||
metaSearchControllerProvider.select((s) {
|
metaSearchControllerProvider.select((s) {
|
||||||
var ready = 0;
|
var ready = 0;
|
||||||
@@ -155,14 +155,27 @@ class _Header extends ConsumerWidget {
|
|||||||
if (s.isMethodReady(result.url, choice)) ready++;
|
if (s.isMethodReady(result.url, choice)) ready++;
|
||||||
}
|
}
|
||||||
final busy = s.isFetching(result.url) || s.isAnyCapturing(result.url);
|
final busy = s.isFetching(result.url) || s.isAnyCapturing(result.url);
|
||||||
return (open: s.hasOpenSession, ready: ready, busy: busy);
|
// Any capture/preview artifact produced for this URL, in any state
|
||||||
|
// (ready, downloading, or failed) — distinct from `ready`, which only
|
||||||
|
// counts the openable ones.
|
||||||
|
final hasArtifacts =
|
||||||
|
s.capturesFor(result.url).isNotEmpty || s.isFetched(result.url);
|
||||||
|
return (
|
||||||
|
open: s.hasOpenSession,
|
||||||
|
ready: ready,
|
||||||
|
busy: busy,
|
||||||
|
hasArtifacts: hasArtifacts,
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Once the WebSocket session has closed no further fetch/capture commands
|
// Keep the button reachable while the session is open (new captures
|
||||||
// can be issued — keep the button only while the session is open or there
|
// possible), while anything is in flight, or whenever artifacts exist for
|
||||||
// are already-fetched artifacts to (re)open via the sheet.
|
// this result. After the socket closes the sheet itself greys out every
|
||||||
final showFetch = fetch.open || fetch.ready > 0;
|
// capture-endpoint action (see _MethodTile.enabled) — a ready artifact
|
||||||
|
// still opens locally, a failed one stays visible with its error. This
|
||||||
|
// only governs whether that sheet is reachable, not what it permits.
|
||||||
|
final showFetch = fetch.open || fetch.busy || fetch.hasArtifacts;
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
+9
-17
@@ -168,26 +168,18 @@ class WebSearchInfoboxCard extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Attributes worth rendering in the factsheet: those with a non-empty value,
|
/// Attributes worth rendering in the factsheet: those with a non-empty value,
|
||||||
/// minus low-signal entries. In particular a lone "type"/"kind" attribute
|
/// minus low-signal entries. We always drop a "type"/"kind" attribute: it is
|
||||||
/// whose value just restates the infobox category (e.g. `Type: Code`) adds
|
/// Brave's weakest classifier (emitted only as a fallback when no `category`
|
||||||
/// nothing the header doesn't already convey, so we drop the whole factsheet
|
/// is available) and as a single taxonomy word (e.g. `Type: Code`) it tells
|
||||||
/// in that case rather than show a one-line, oddly-centered tile.
|
/// the user nothing the heading/image/links don't already convey.
|
||||||
static List<InfoboxAttribute> _meaningfulAttributes(CompactInfobox info) {
|
static List<InfoboxAttribute> _meaningfulAttributes(CompactInfobox info) {
|
||||||
final attributes = (info.attributes ?? const <InfoboxAttribute>[])
|
return (info.attributes ?? const <InfoboxAttribute>[])
|
||||||
.where((attr) => attr.value?.trim().isNotEmpty ?? false)
|
.where((attr) => attr.value?.trim().isNotEmpty ?? false)
|
||||||
|
.where((attr) {
|
||||||
|
final label = attr.label.replaceAll(RegExp(r':+\s*$'), '').toLowerCase();
|
||||||
|
return label != 'type' && label != 'kind';
|
||||||
|
})
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
if (attributes.length == 1) {
|
|
||||||
final only = attributes.single;
|
|
||||||
final label = only.label.replaceAll(RegExp(r':+\s*$'), '').toLowerCase();
|
|
||||||
final value = only.value!.trim().toLowerCase();
|
|
||||||
if ((label == 'type' || label == 'kind') &&
|
|
||||||
value == info.infobox.trim().toLowerCase()) {
|
|
||||||
return const [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return attributes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Link chips to show. These are the card's primary actionable content — the
|
/// Link chips to show. These are the card's primary actionable content — the
|
||||||
|
|||||||
Reference in New Issue
Block a user