[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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user