increase min sdk and apply new formatter
This commit is contained in:
@@ -21,8 +21,9 @@ class ChatArchiveRepository extends _$ChatArchiveRepository {
|
||||
}
|
||||
|
||||
Future<Result<void>> archiveChat(String fileName, Uri url) async {
|
||||
final contentsResult =
|
||||
await ref.read(kagiChatServiceProvider.notifier).downloadChat(url);
|
||||
final contentsResult = await ref
|
||||
.read(kagiChatServiceProvider.notifier)
|
||||
.downloadChat(url);
|
||||
|
||||
return contentsResult.flatMapAsync(
|
||||
(contents) => ref
|
||||
@@ -37,14 +38,15 @@ class ChatArchiveRepository extends _$ChatArchiveRepository {
|
||||
);
|
||||
|
||||
return contentsResult.fold(
|
||||
(value) => (value == null)
|
||||
? Result.failure(
|
||||
ErrorMessage(
|
||||
source: 'Chat Archive',
|
||||
message: 'Chat $fileName not found',
|
||||
),
|
||||
)
|
||||
: Result.success(value),
|
||||
(value) =>
|
||||
(value == null)
|
||||
? Result.failure(
|
||||
ErrorMessage(
|
||||
source: 'Chat Archive',
|
||||
message: 'Chat $fileName not found',
|
||||
),
|
||||
)
|
||||
: Result.success(value),
|
||||
onFailure: Result.failure,
|
||||
);
|
||||
}
|
||||
@@ -55,17 +57,16 @@ class ChatArchiveRepository extends _$ChatArchiveRepository {
|
||||
|
||||
yield* ConcatStream([
|
||||
listArchivedChats().asStream(),
|
||||
fileRepository.asyncMap(
|
||||
(_) => listArchivedChats(),
|
||||
),
|
||||
fileRepository.asyncMap((_) => listArchivedChats()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@Riverpod()
|
||||
Future<String> readArchivedChat(Ref ref, String fileName) async {
|
||||
final result =
|
||||
await ref.read(chatArchiveRepositoryProvider.notifier).readChat(fileName);
|
||||
final result = await ref
|
||||
.read(chatArchiveRepositoryProvider.notifier)
|
||||
.readChat(fileName);
|
||||
|
||||
return result.value;
|
||||
}
|
||||
|
||||
@@ -39,21 +39,15 @@ class ReadArchivedChatFamily extends Family<AsyncValue<String>> {
|
||||
const ReadArchivedChatFamily();
|
||||
|
||||
/// See also [readArchivedChat].
|
||||
ReadArchivedChatProvider call(
|
||||
String fileName,
|
||||
) {
|
||||
return ReadArchivedChatProvider(
|
||||
fileName,
|
||||
);
|
||||
ReadArchivedChatProvider call(String fileName) {
|
||||
return ReadArchivedChatProvider(fileName);
|
||||
}
|
||||
|
||||
@override
|
||||
ReadArchivedChatProvider getProviderOverride(
|
||||
covariant ReadArchivedChatProvider provider,
|
||||
) {
|
||||
return call(
|
||||
provider.fileName,
|
||||
);
|
||||
return call(provider.fileName);
|
||||
}
|
||||
|
||||
static const Iterable<ProviderOrFamily>? _dependencies = null;
|
||||
@@ -74,24 +68,20 @@ class ReadArchivedChatFamily extends Family<AsyncValue<String>> {
|
||||
/// See also [readArchivedChat].
|
||||
class ReadArchivedChatProvider extends AutoDisposeFutureProvider<String> {
|
||||
/// See also [readArchivedChat].
|
||||
ReadArchivedChatProvider(
|
||||
String fileName,
|
||||
) : this._internal(
|
||||
(ref) => readArchivedChat(
|
||||
ref as ReadArchivedChatRef,
|
||||
fileName,
|
||||
),
|
||||
from: readArchivedChatProvider,
|
||||
name: r'readArchivedChatProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$readArchivedChatHash,
|
||||
dependencies: ReadArchivedChatFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
ReadArchivedChatFamily._allTransitiveDependencies,
|
||||
fileName: fileName,
|
||||
);
|
||||
ReadArchivedChatProvider(String fileName)
|
||||
: this._internal(
|
||||
(ref) => readArchivedChat(ref as ReadArchivedChatRef, fileName),
|
||||
from: readArchivedChatProvider,
|
||||
name: r'readArchivedChatProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$readArchivedChatHash,
|
||||
dependencies: ReadArchivedChatFamily._dependencies,
|
||||
allTransitiveDependencies:
|
||||
ReadArchivedChatFamily._allTransitiveDependencies,
|
||||
fileName: fileName,
|
||||
);
|
||||
|
||||
ReadArchivedChatProvider._internal(
|
||||
super._createNotifier, {
|
||||
@@ -150,7 +140,8 @@ mixin ReadArchivedChatRef on AutoDisposeFutureProviderRef<String> {
|
||||
}
|
||||
|
||||
class _ReadArchivedChatProviderElement
|
||||
extends AutoDisposeFutureProviderElement<String> with ReadArchivedChatRef {
|
||||
extends AutoDisposeFutureProviderElement<String>
|
||||
with ReadArchivedChatRef {
|
||||
_ReadArchivedChatProviderElement(super.provider);
|
||||
|
||||
@override
|
||||
@@ -163,12 +154,15 @@ String _$chatArchiveRepositoryHash() =>
|
||||
/// See also [ChatArchiveRepository].
|
||||
@ProviderFor(ChatArchiveRepository)
|
||||
final chatArchiveRepositoryProvider = AutoDisposeStreamNotifierProvider<
|
||||
ChatArchiveRepository, List<ChatEntity>>.internal(
|
||||
ChatArchiveRepository,
|
||||
List<ChatEntity>
|
||||
>.internal(
|
||||
ChatArchiveRepository.new,
|
||||
name: r'chatArchiveRepositoryProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$chatArchiveRepositoryHash,
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$chatArchiveRepositoryHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@@ -74,13 +74,11 @@ class ChatArchiveSearchRepository extends _$ChatArchiveSearchRepository {
|
||||
ellipsis: ellipsis,
|
||||
)
|
||||
.get()
|
||||
.then(
|
||||
(value) {
|
||||
if (!_streamController.isClosed) {
|
||||
_streamController.add(value);
|
||||
}
|
||||
},
|
||||
);
|
||||
.then((value) {
|
||||
if (!_streamController.isClosed) {
|
||||
_streamController.add(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,23 +94,24 @@ class ChatArchiveSearchRepository extends _$ChatArchiveSearchRepository {
|
||||
await searchDatabase.searchDao.indexChats(await _availableChats());
|
||||
_populatedCompleter.complete();
|
||||
|
||||
final changeStreamSubscription =
|
||||
ref.watch(chatArchiveFileServiceProvider).listen((event) async {
|
||||
final chat = ChatEntity.fromFileName(path.basename(event.path));
|
||||
final changeStreamSubscription = ref
|
||||
.watch(chatArchiveFileServiceProvider)
|
||||
.listen((event) async {
|
||||
final chat = ChatEntity.fromFileName(path.basename(event.path));
|
||||
|
||||
switch (event.type) {
|
||||
case ChangeType.ADD:
|
||||
case ChangeType.MODIFY:
|
||||
if (chat.name != null) {
|
||||
final companion = await _readChat(chat);
|
||||
if (companion != null) {
|
||||
await searchDatabase.searchDao.upsertChat(companion);
|
||||
}
|
||||
switch (event.type) {
|
||||
case ChangeType.ADD:
|
||||
case ChangeType.MODIFY:
|
||||
if (chat.name != null) {
|
||||
final companion = await _readChat(chat);
|
||||
if (companion != null) {
|
||||
await searchDatabase.searchDao.upsertChat(companion);
|
||||
}
|
||||
}
|
||||
case ChangeType.REMOVE:
|
||||
await searchDatabase.searchDao.deleteChat(chat.fileName);
|
||||
}
|
||||
case ChangeType.REMOVE:
|
||||
await searchDatabase.searchDao.deleteChat(chat.fileName);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ref.onDispose(() async {
|
||||
await changeStreamSubscription.cancel();
|
||||
|
||||
@@ -12,17 +12,20 @@ String _$chatArchiveSearchRepositoryHash() =>
|
||||
/// See also [ChatArchiveSearchRepository].
|
||||
@ProviderFor(ChatArchiveSearchRepository)
|
||||
final chatArchiveSearchRepositoryProvider = AutoDisposeStreamNotifierProvider<
|
||||
ChatArchiveSearchRepository, List<ChatQueryResult>>.internal(
|
||||
ChatArchiveSearchRepository,
|
||||
List<ChatQueryResult>
|
||||
>.internal(
|
||||
ChatArchiveSearchRepository.new,
|
||||
name: r'chatArchiveSearchRepositoryProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$chatArchiveSearchRepositoryHash,
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$chatArchiveSearchRepositoryHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$ChatArchiveSearchRepository
|
||||
= AutoDisposeStreamNotifier<List<ChatQueryResult>>;
|
||||
typedef _$ChatArchiveSearchRepository =
|
||||
AutoDisposeStreamNotifier<List<ChatQueryResult>>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
|
||||
|
||||
Reference in New Issue
Block a user