feat: add HTML providers for Realbooru and Paheal, hidden posts screen, and UI/search enhancements

This commit is contained in:
2026-09-03 16:40:37 +03:00
parent 7cccb2cd8d
commit 45faa12133
55 changed files with 4263 additions and 2076 deletions
@@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../backend/backend.dart';
@@ -8,8 +10,12 @@ final searchControllerProvider =
AsyncNotifierProvider<SearchController, SearchState>(SearchController.new);
class SearchController extends AsyncNotifier<SearchState> {
Timer? _suggestionDebounce;
int _suggestionRequestId = 0;
@override
Future<SearchState> build() async {
ref.onDispose(() => _suggestionDebounce?.cancel());
final recent = await _recent();
return SearchState(recent: recent);
}
@@ -17,18 +23,42 @@ class SearchController extends AsyncNotifier<SearchState> {
Future<void> updateQuery(String query) async {
final lastToken =
query.trim().isEmpty ? '' : query.trim().split(RegExp(r'\s+')).last;
final suggestionsResult = await ref
.read(searchServiceProvider)
.autocompleteDetailed(lastToken, limit: 16);
final suggestions = suggestionsResult is Success<List<TagSuggestion>>
? suggestionsResult.data
: <TagSuggestion>[];
final requestId = ++_suggestionRequestId;
_suggestionDebounce?.cancel();
if (lastToken.isEmpty) {
state = AsyncData(
(state.value ?? const SearchState()).copyWith(
query: query,
suggestions: const [],
),
);
return;
}
state = AsyncData(
(state.value ?? const SearchState()).copyWith(
query: query,
suggestions: suggestions,
),
);
_suggestionDebounce = Timer(const Duration(milliseconds: 280), () async {
final suggestionsResult = await ref
.read(searchServiceProvider)
.autocompleteDetailed(lastToken, limit: 16);
if (requestId != _suggestionRequestId) return;
final normalizedToken = lastToken.trim().toLowerCase();
final suggestions = suggestionsResult is Success<List<TagSuggestion>>
? suggestionsResult.data
.where((item) => item.name.toLowerCase().startsWith(
normalizedToken,
))
.toList(growable: false)
: <TagSuggestion>[];
state = AsyncData(
(state.value ?? const SearchState()).copyWith(
query: query,
suggestions: suggestions,
),
);
});
}
Future<void> clearHistory() async {