push
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'package:lensai/extensions/nullable.dart';
|
||||
|
||||
class ChatEntity {
|
||||
static final _namePattern = RegExp(r"^(.*?) - (.*?)\.md$");
|
||||
|
||||
@@ -14,7 +16,7 @@ class ChatEntity {
|
||||
return ChatEntity._(
|
||||
fileName,
|
||||
name: match?.group(1),
|
||||
dateTime: (match != null) ? DateTime.tryParse(match.group(2)!) : null,
|
||||
dateTime: match.mapNotNull((match) => DateTime.tryParse(match.group(2)!)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ part 'search.g.dart';
|
||||
class ChatArchiveSearchRepository extends _$ChatArchiveSearchRepository {
|
||||
late Completer<void> _populatedCompleter;
|
||||
late StreamController<List<ChatQueryResult>> _streamController;
|
||||
late ChatSearchDatabase _searchDatabase;
|
||||
|
||||
Future<ChatCompanion?> _readChat(ChatEntity chat) async {
|
||||
final contentResult = await ref
|
||||
@@ -64,7 +63,9 @@ class ChatArchiveSearchRepository extends _$ChatArchiveSearchRepository {
|
||||
}) async {
|
||||
if (input.isNotEmpty) {
|
||||
await _populatedCompleter.future;
|
||||
await _searchDatabase.searchDao
|
||||
await ref
|
||||
.read(chatSearchDatabaseProvider)
|
||||
.searchDao
|
||||
.queryChats(
|
||||
searchString: input,
|
||||
snippetLength: snippetLength,
|
||||
@@ -81,11 +82,12 @@ class ChatArchiveSearchRepository extends _$ChatArchiveSearchRepository {
|
||||
Stream<List<ChatQueryResult>> build() async* {
|
||||
_populatedCompleter = Completer();
|
||||
_streamController = StreamController();
|
||||
_searchDatabase = ref.watch(chatSearchDatabaseProvider);
|
||||
|
||||
final searchDatabase = ref.watch(chatSearchDatabaseProvider);
|
||||
|
||||
// populate with initial chats
|
||||
await _searchDatabase.searchDao.deleteAllChats();
|
||||
await _searchDatabase.searchDao.indexChats(await _availableChats());
|
||||
await searchDatabase.searchDao.deleteAllChats();
|
||||
await searchDatabase.searchDao.indexChats(await _availableChats());
|
||||
_populatedCompleter.complete();
|
||||
|
||||
final changeStreamSubscription =
|
||||
@@ -98,11 +100,11 @@ class ChatArchiveSearchRepository extends _$ChatArchiveSearchRepository {
|
||||
if (chat.name != null) {
|
||||
final companion = await _readChat(chat);
|
||||
if (companion != null) {
|
||||
await _searchDatabase.searchDao.upsertChat(companion);
|
||||
await searchDatabase.searchDao.upsertChat(companion);
|
||||
}
|
||||
}
|
||||
case ChangeType.REMOVE:
|
||||
await _searchDatabase.searchDao.deleteChat(chat.fileName);
|
||||
await searchDatabase.searchDao.deleteChat(chat.fileName);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ part of 'search.dart';
|
||||
// **************************************************************************
|
||||
|
||||
String _$chatArchiveSearchRepositoryHash() =>
|
||||
r'd7174cfb877c61ee4e9580f44d7ffd11bf3b4b60';
|
||||
r'6762958d43d2efc95f5d9848bfcae41436564f2b';
|
||||
|
||||
/// See also [ChatArchiveSearchRepository].
|
||||
@ProviderFor(ChatArchiveSearchRepository)
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:lensai/core/routing/routes.dart';
|
||||
import 'package:lensai/extensions/date_time.dart';
|
||||
import 'package:lensai/extensions/nullable.dart';
|
||||
import 'package:lensai/features/chat_archive/domain/repositories/archive.dart';
|
||||
import 'package:lensai/presentation/widgets/failure_widget.dart';
|
||||
import 'package:skeletonizer/skeletonizer.dart';
|
||||
@@ -41,9 +42,10 @@ class ChatArchiveListScreen extends HookConsumerWidget {
|
||||
|
||||
return ListTile(
|
||||
title: Text(chat.toString()),
|
||||
subtitle: (chat.dateTime != null)
|
||||
? Text(chat.dateTime!.formatWithMinutePrecision())
|
||||
: null,
|
||||
subtitle: chat.dateTime.mapNotNull(
|
||||
(chatTime) =>
|
||||
Text(chatTime.formatWithMinutePrecision()),
|
||||
),
|
||||
onTap: () async {
|
||||
await context.push(
|
||||
ChatArchiveDetailRoute(fileName: chat.fileName)
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:lensai/core/routing/routes.dart';
|
||||
import 'package:lensai/extensions/date_time.dart';
|
||||
import 'package:lensai/features/chat_archive/domain/entities/chat_entity.dart';
|
||||
import 'package:lensai/features/chat_archive/domain/repositories/search.dart';
|
||||
import 'package:lensai/features/user/domain/repositories/settings.dart';
|
||||
import 'package:lensai/features/user/domain/providers.dart';
|
||||
import 'package:lensai/presentation/hooks/listenable_callback.dart';
|
||||
import 'package:lensai/presentation/widgets/failure_widget.dart';
|
||||
|
||||
@@ -20,9 +20,7 @@ class ChatArchiveSearchScreen extends HookConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final resultsAsync = ref.watch(chatArchiveSearchRepositoryProvider);
|
||||
final incognitoEnabled = ref.watch(
|
||||
settingsRepositoryProvider.select((value) => value.incognitoMode),
|
||||
);
|
||||
final incognitoEnabled = ref.watch(incognitoModeEnabledProvider);
|
||||
|
||||
final textEditingController = useTextEditingController();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user