[REF] unify pool handling with extension methods

- Move pool filtering and parsing logic into SnFilePool extension
- Replace PoolService and pool_utils with unified extension
- Update settings screen to use pools.filterValid() + resolveDefaultPoolId
- Cleanup references in compose_shared.dart
- Remove obsolete files: pool_service.dart, pool_utils.dart

Signed-off-by: Texas0295 <kimura@texas0295.top>
This commit is contained in:
Texas0295
2025-09-21 22:10:25 +08:00
parent cbdc7acdcd
commit 1391fa0dde
6 changed files with 48 additions and 77 deletions

View File

@@ -24,7 +24,7 @@ sealed class SnFilePool with _$SnFilePool {
_$SnFilePoolFromJson(json);
}
extension SnFilePoolList on SnFilePool {
extension SnFilePoolList on List<SnFilePool> {
static List<SnFilePool> listFromResponse(dynamic data) {
if (data is List) {
return data
@@ -34,4 +34,20 @@ extension SnFilePoolList on SnFilePool {
}
throw ArgumentError('Unexpected response format: $data');
}
List<SnFilePool> filterValid() {
return where((p) {
final accept = p.policyConfig?['accept_types'];
if (accept is List) {
final acceptsOnlyMedia = accept.every((t) =>
t is String &&
(t.startsWith('image/') ||
t.startsWith('video/') ||
t.startsWith('audio/')));
if (acceptsOnlyMedia) return false;
}
return true;
}).toList();
}
}