feat: improve recent searches and tags visibility, deduplication and UI (v3.0.6)
Build and Release / Build Windows x64 (push) Has been cancelled

This commit is contained in:
2026-09-04 18:06:46 +03:00
parent 6f902740c1
commit dff2cd806d
8 changed files with 149 additions and 39 deletions
+1 -1
View File
@@ -10,7 +10,7 @@
</p> </p>
<p align="center"> <p align="center">
<a href="https://github.com/RarDog/Lunaris/releases"><img src="https://img.shields.io/badge/Version-3.0.5-8A2BE2?style=for-the-badge&logo=semver&logoColor=white" alt="Version 3.0.5" /></a> <a href="https://github.com/RarDog/Lunaris/releases"><img src="https://img.shields.io/badge/Version-3.0.6-8A2BE2?style=for-the-badge&logo=semver&logoColor=white" alt="Version 3.0.6" /></a>
<img src="https://img.shields.io/badge/Flutter-3.47+-02569B?style=for-the-badge&logo=flutter&logoColor=white" alt="Flutter" /> <img src="https://img.shields.io/badge/Flutter-3.47+-02569B?style=for-the-badge&logo=flutter&logoColor=white" alt="Flutter" />
<img src="https://img.shields.io/badge/Platform-Android%20%7C%20Linux%20%7C%20Windows-00C853?style=for-the-badge" alt="Platforms" /> <img src="https://img.shields.io/badge/Platform-Android%20%7C%20Linux%20%7C%20Windows-00C853?style=for-the-badge" alt="Platforms" />
<a href="https://github.com/RarDog/Lunaris/wiki"><img src="https://img.shields.io/badge/Wiki-Documentation-FF6F00?style=for-the-badge&logo=gitbook&logoColor=white" alt="Wiki" /></a> <a href="https://github.com/RarDog/Lunaris/wiki"><img src="https://img.shields.io/badge/Wiki-Documentation-FF6F00?style=for-the-badge&logo=gitbook&logoColor=white" alt="Wiki" /></a>
+2 -2
View File
@@ -1,3 +1,3 @@
const appDisplayVersion = '3.0.5'; const appDisplayVersion = '3.0.6';
const appBuildNumber = 56; const appBuildNumber = 57;
const appReleaseChannel = 'Stable'; const appReleaseChannel = 'Stable';
+10
View File
@@ -1,4 +1,14 @@
const lunarisChangelog = [ const lunarisChangelog = [
LunarisChange(
version: '3.0.6',
title: 'Улучшение недавних запросов и отображения тегов',
bullets: [
'Полная видимость тегов и запросов: сняты тесные ограничения ширины (140px), теги и поисковые запросы теперь отображаются целиком без усечения.',
'Устранение дубликатов в истории: автоматическая дедупликация поисковых запросов в базе данных и интерфейсе. Устранены повторяющиеся пары запросов с пустыми счетчиками.',
'Исправление заголовка карточки поиска: заголовок «Недавние запросы» и счетчик больше не обрезаются на экранах смартфонов.',
'Удобное удаление: увеличенная область нажатия для кнопки удаления (крестика) предотвращает случайные нажатия на сам запрос.',
],
),
LunarisChange( LunarisChange(
version: '3.0.5', version: '3.0.5',
title: 'Интерактивные ссылки на соцсети и авторов в объявлениях и описаниях', title: 'Интерактивные ссылки на соцсети и авторов в объявлениях и описаниях',
@@ -12,6 +12,15 @@ class SearchRepository {
Future<Result<void>> save(SearchHistory history, {int maxItems = 500}) { Future<Result<void>> save(SearchHistory history, {int maxItems = 500}) {
return _databaseService.safeWrite((isar) async { return _databaseService.safeWrite((isar) async {
final norm = history.query.trim().toLowerCase();
// Remove any existing duplicate records with same query
final all = await isar.searchHistoryEntitys.where().findAll();
for (final item in all) {
if (item.query.trim().toLowerCase() == norm) {
await isar.searchHistoryEntitys.delete(item.isarId);
}
}
await isar.searchHistoryEntitys.put( await isar.searchHistoryEntitys.put(
SearchHistoryEntity() SearchHistoryEntity()
..historyId = history.id ..historyId = history.id
@@ -42,13 +51,40 @@ class SearchRepository {
return _databaseService.safeRead((isar) async { return _databaseService.safeRead((isar) async {
final items = await isar.searchHistoryEntitys.where().findAll(); final items = await isar.searchHistoryEntitys.where().findAll();
items.sort((a, b) => b.searchedAt.compareTo(a.searchedAt)); items.sort((a, b) => b.searchedAt.compareTo(a.searchedAt));
final limited = limit == null ? items : items.take(limit);
final seen = <String>{};
final deduplicated = <SearchHistoryEntity>[];
for (final item in items) {
final key = item.query.trim().toLowerCase();
if (key.isEmpty) continue;
if (seen.add(key)) {
deduplicated.add(item);
}
}
final limited = limit == null ? deduplicated : deduplicated.take(limit);
return limited.map((entity) => entity.toModel()).toList(); return limited.map((entity) => entity.toModel()).toList();
}); });
} }
Future<Result<bool>> delete(String historyId) { Future<Result<bool>> delete(String historyId) {
return _databaseService.safeWrite((isar) async { return _databaseService.safeWrite((isar) async {
final target = await isar.searchHistoryEntitys
.where()
.filter()
.historyIdEqualTo(historyId)
.findFirst();
if (target != null) {
final norm = target.query.trim().toLowerCase();
final all = await isar.searchHistoryEntitys.where().findAll();
for (final item in all) {
if (item.query.trim().toLowerCase() == norm ||
item.historyId == historyId) {
await isar.searchHistoryEntitys.delete(item.isarId);
}
}
return true;
}
return await isar.searchHistoryEntitys.deleteByHistoryId(historyId); return await isar.searchHistoryEntitys.deleteByHistoryId(historyId);
}); });
} }
@@ -123,14 +123,18 @@ class FeedController extends AsyncNotifier<FeedState> {
final settingsRes = await ref.read(settingsServiceProvider).getSettings(); final settingsRes = await ref.read(settingsServiceProvider).getSettings();
final settings = final settings =
settingsRes is Success<AppSettings> ? settingsRes.data : AppSettings.defaults; settingsRes is Success<AppSettings> ? settingsRes.data : AppSettings.defaults;
await ref try {
.read(searchServiceProvider) await refresh();
.saveSearch(query, 0, maxHistory: settings.searchHistoryLimit); final count = state.value?.posts.length ?? 0;
await refresh(); await ref
final count = state.value?.posts.length ?? 0; .read(searchServiceProvider)
await ref .saveSearch(query, count, maxHistory: settings.searchHistoryLimit);
.read(searchServiceProvider) } catch (_) {
.saveSearch(query, count, maxHistory: settings.searchHistoryLimit); await ref
.read(searchServiceProvider)
.saveSearch(query, 0, maxHistory: settings.searchHistoryLimit);
rethrow;
}
} }
Future<void> updateTagSuggestions(String query) async { Future<void> updateTagSuggestions(String query) async {
@@ -175,10 +175,21 @@ class _SearchScreenState extends ConsumerState<SearchScreen> {
icon: Icons.history_rounded, icon: Icons.history_rounded,
accentColor: const Color(0xFF6366F1), accentColor: const Color(0xFF6366F1),
title: isRu ? 'Недавние запросы' : 'Recent searches', title: isRu ? 'Недавние запросы' : 'Recent searches',
badgeCount: data.recent.length, badgeCount: data.recent
.map((e) => e.query.trim().toLowerCase())
.where((q) => q.isNotEmpty)
.toSet()
.length,
trailing: data.recent.isEmpty trailing: data.recent.isEmpty
? null ? null
: TextButton( : TextButton(
style: TextButton.styleFrom(
visualDensity: VisualDensity.compact,
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 4),
minimumSize: Size.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
onPressed: () => ref onPressed: () => ref
.read(searchControllerProvider.notifier) .read(searchControllerProvider.notifier)
.clearHistory(), .clearHistory(),
@@ -390,9 +401,10 @@ class _SearchSectionCard extends StatelessWidget {
), ),
child: Icon(icon, size: 18, color: accentColor), child: Icon(icon, size: 18, color: accentColor),
), ),
const SizedBox(width: 12), const SizedBox(width: 10),
Expanded( Expanded(
child: Row( child: Row(
mainAxisSize: MainAxisSize.min,
children: [ children: [
Flexible( Flexible(
child: Text( child: Text(
@@ -401,6 +413,7 @@ class _SearchSectionCard extends StatelessWidget {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: theme.textTheme.titleMedium?.copyWith( style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
fontSize: 15,
), ),
), ),
), ),
@@ -408,7 +421,7 @@ class _SearchSectionCard extends StatelessWidget {
const SizedBox(width: 8), const SizedBox(width: 8),
Container( Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 2), horizontal: 7, vertical: 2),
decoration: BoxDecoration( decoration: BoxDecoration(
color: accentColor.withValues(alpha: 0.15), color: accentColor.withValues(alpha: 0.15),
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
@@ -47,8 +47,44 @@ class _RecentSearchesState extends State<RecentSearches> {
); );
} }
// Deduplicate items by normalized query
final seen = <String>{};
final uniqueItems = <SearchHistory>[];
for (final item in widget.items) {
final key = item.query.trim().toLowerCase();
if (key.isEmpty) continue;
if (seen.add(key)) {
uniqueItems.add(item);
}
}
if (uniqueItems.isEmpty) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 16),
alignment: Alignment.center,
child: Column(
children: [
Icon(
Icons.history_toggle_off_rounded,
size: 40,
color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
),
const SizedBox(height: 10),
Text(
'История поиска пуста',
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
],
),
);
}
final visibleItems = final visibleItems =
_expanded ? widget.items : widget.items.take(20).toList(); _expanded ? uniqueItems : uniqueItems.take(20).toList();
final screenW = MediaQuery.sizeOf(context).width;
final maxQueryWidth = (screenW - 200).clamp(180.0, 480.0);
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@@ -66,7 +102,7 @@ class _RecentSearchesState extends State<RecentSearches> {
onTap: () => widget.onTap(item.query), onTap: () => widget.onTap(item.query),
child: Container( child: Container(
padding: padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 6), const EdgeInsets.only(left: 10, right: 6, top: 6, bottom: 6),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
border: Border.all( border: Border.all(
@@ -79,18 +115,22 @@ class _RecentSearchesState extends State<RecentSearches> {
children: [ children: [
Icon( Icon(
Icons.history_rounded, Icons.history_rounded,
size: 14, size: 15,
color: theme.colorScheme.primary, color: theme.colorScheme.primary,
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
ConstrainedBox( ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 140), constraints: BoxConstraints(maxWidth: maxQueryWidth),
child: Text( child: Tooltip(
item.query, message: item.query,
maxLines: 1, waitDuration: const Duration(milliseconds: 600),
overflow: TextOverflow.ellipsis, child: Text(
style: theme.textTheme.bodyMedium?.copyWith( item.query,
fontWeight: FontWeight.w500, maxLines: 1,
overflow: TextOverflow.ellipsis,
style: theme.textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w600,
),
), ),
), ),
), ),
@@ -100,14 +140,14 @@ class _RecentSearchesState extends State<RecentSearches> {
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 6, vertical: 2), horizontal: 6, vertical: 2),
decoration: BoxDecoration( decoration: BoxDecoration(
color: theme.colorScheme.secondaryContainer, color: theme.colorScheme.primary.withValues(alpha: 0.12),
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
child: Text( child: Text(
'${item.resultCount}', '${item.resultCount}',
style: theme.textTheme.labelSmall?.copyWith( style: theme.textTheme.labelSmall?.copyWith(
color: theme.colorScheme.onSecondaryContainer, color: theme.colorScheme.primary,
fontSize: 10, fontSize: 11,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
@@ -115,14 +155,21 @@ class _RecentSearchesState extends State<RecentSearches> {
], ],
if (widget.onDelete != null) ...[ if (widget.onDelete != null) ...[
const SizedBox(width: 4), const SizedBox(width: 4),
GestureDetector( Material(
onTap: () => widget.onDelete!(item.id), color: Colors.transparent,
child: Padding( shape: const CircleBorder(),
padding: const EdgeInsets.all(2), clipBehavior: Clip.antiAlias,
child: Icon( child: InkWell(
Icons.close_rounded, customBorder: const CircleBorder(),
size: 14, onTap: () => widget.onDelete!(item.id),
color: theme.colorScheme.onSurfaceVariant, child: Padding(
padding: const EdgeInsets.all(4),
child: Icon(
Icons.close_rounded,
size: 15,
color: theme.colorScheme.onSurfaceVariant
.withValues(alpha: 0.75),
),
), ),
), ),
), ),
@@ -134,7 +181,7 @@ class _RecentSearchesState extends State<RecentSearches> {
), ),
], ],
), ),
if (widget.items.length > 20) ...[ if (uniqueItems.length > 20) ...[
const SizedBox(height: 10), const SizedBox(height: 10),
Center( Center(
child: TextButton.icon( child: TextButton.icon(
@@ -148,7 +195,7 @@ class _RecentSearchesState extends State<RecentSearches> {
label: Text( label: Text(
_expanded _expanded
? 'Свернуть' ? 'Свернуть'
: 'Показать все (${widget.items.length})', : 'Показать все (${uniqueItems.length})',
), ),
), ),
), ),
+1 -1
View File
@@ -1,7 +1,7 @@
name: gel_rule_app name: gel_rule_app
description: Local backend/core layer for a Flutter booru browser app. description: Local backend/core layer for a Flutter booru browser app.
publish_to: "none" publish_to: "none"
version: 3.0.5+56 version: 3.0.6+57
environment: environment:
sdk: ">=3.3.0 <4.0.0" sdk: ">=3.3.0 <4.0.0"