switch to top recent sites
This commit is contained in:
@@ -70,6 +70,17 @@ class HistoryRepository extends _$HistoryRepository {
|
||||
);
|
||||
}
|
||||
|
||||
Future<List<TopFrecentSiteInfo>> getTopFrecentSites({
|
||||
required int limit,
|
||||
FrecencyThresholdOption frecencyThreshold =
|
||||
FrecencyThresholdOption.skipOneTimePages,
|
||||
}) {
|
||||
return _service.getTopFrecentSites(
|
||||
limit: limit,
|
||||
frecencyThreshold: frecencyThreshold,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void build() {}
|
||||
}
|
||||
|
||||
@@ -631,10 +631,9 @@ class SearchScreen extends HookConsumerWidget {
|
||||
for (final entry in emptyStateOrder)
|
||||
if (emptyStateWidgets.containsKey(entry.type))
|
||||
emptyStateWidgets[entry.type]!,
|
||||
if (!emptyStateOrder.any((e) => e.visible))
|
||||
const _CustomizeSectionsButton(
|
||||
group: SearchModuleGroup.emptyState,
|
||||
),
|
||||
const _CustomizeSectionsButton(
|
||||
group: SearchModuleGroup.emptyState,
|
||||
),
|
||||
] else ...[
|
||||
FullSearchTermSuggestions(
|
||||
searchTextController: searchTextController,
|
||||
@@ -645,10 +644,9 @@ class SearchScreen extends HookConsumerWidget {
|
||||
for (final entry in searchOrder)
|
||||
if (searchWidgets.containsKey(entry.type))
|
||||
searchWidgets[entry.type]!,
|
||||
if (!searchOrder.any((e) => e.visible))
|
||||
const _CustomizeSectionsButton(
|
||||
group: SearchModuleGroup.search,
|
||||
),
|
||||
const _CustomizeSectionsButton(
|
||||
group: SearchModuleGroup.search,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
||||
+7
-14
@@ -248,32 +248,25 @@ class TopSiteRepository extends _$TopSiteRepository {
|
||||
required int limit,
|
||||
required Set<String> excludeUrls,
|
||||
}) async {
|
||||
final highlights = await ref
|
||||
final frecentSites = await ref
|
||||
.read(historyRepositoryProvider.notifier)
|
||||
.getHistoryHighlights(limit: limit + excludeUrls.length);
|
||||
.getTopFrecentSites(limit: limit + excludeUrls.length);
|
||||
|
||||
final items = <TopSiteItem>[];
|
||||
for (final h in highlights) {
|
||||
for (final site in frecentSites) {
|
||||
if (items.length >= limit) break;
|
||||
|
||||
final uri = Uri.tryParse(h.url);
|
||||
final uri = Uri.tryParse(site.url);
|
||||
if (uri == null) continue;
|
||||
|
||||
if (excludeUrls.contains(uri.toString())) continue;
|
||||
|
||||
final title = (h.title?.trim().isNotEmpty == true)
|
||||
? h.title!.trim()
|
||||
final title = (site.title?.trim().isNotEmpty == true)
|
||||
? site.title!.trim()
|
||||
: uri.host;
|
||||
|
||||
items.add(
|
||||
TopSiteItem(
|
||||
title: title,
|
||||
url: uri,
|
||||
source: TopSiteSource.history,
|
||||
previewImageUrl: h.previewImageUrl,
|
||||
historyScore: h.score,
|
||||
historyPlaceId: h.placeId,
|
||||
),
|
||||
TopSiteItem(title: title, url: uri, source: TopSiteSource.history),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user