feat(app): block selecting already-uploaded photos at picker tap (double-tap to force)
方案 A(选图点选拦截):multiImagePickerProvider 经 wechat_assets_picker 10.1.3 官方钩子 AssetPickerConfig.selectPredicate 挂 PickerDuplicateGate—— 点选「已上传到目标相册」的照片当场拦下(SnackBar 提示),再次点击同一张 强制选择(escape hatch)。 - MultiImagePicker typedef 增参 accountId/albumId(拦截判定范围=当前 目标相册;相册详情/连拍页两处调用点传入); - 判定口径同 checkDuplicatesUnified:本机 TaskStore(同账号+相册+ completed,filename+bytes)∪ 服务器单项预检(bytes;本机命中短路 服务器,点选延迟考量);任一半场异常按该半场无命中,fileSize 失败等 整体异常直接放行——enqueue 弹窗 + init 409 兜底不变; - per-asset 判定缓存(二次点击瞬回)+ 二次点击放行集;取消选择恒放行 且不预热放行集; - AssetEntity 事实适配(PickerAssetFact 测试接缝):fileSize 为 photo_manager 3.12 的 Future<int> 平台通道 getter(entity.dart:778), 惰性求值;title 为 String?(Android 恒有值;iOS 需 needTitle——null 时本机半场跳过,服务器按 bytes 仍可判); - l10n pickerDuplicateBlocked(zh/en);测试替身签名同步 (album_detail/capture_page 页测 + integration_test app_boot), 页测补 (accountId, albumId) 接线断言;gate 五态用例入 enqueue_test。 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -105,6 +105,8 @@ void main() {
|
||||
late Directory tmp;
|
||||
late FakeCaptureSource source;
|
||||
late List<String> galleryPaths;
|
||||
// 方案 A 接线断言:选图器收到的 (accountId, albumId)。
|
||||
late List<(String, String)> pickerScopes;
|
||||
|
||||
/// 工厂调用记录(前后摄切换断言)。
|
||||
late List<bool> factoryPreferFront;
|
||||
@@ -144,6 +146,7 @@ void main() {
|
||||
final shot3 = File('${tmp.path}/IMG_0003.jpg')..writeAsBytesSync(kJpgBytes);
|
||||
source = FakeCaptureSource([shot1, shot2, shot3]);
|
||||
galleryPaths = <String>[];
|
||||
pickerScopes = <(String, String)>[];
|
||||
factoryPreferFront = <bool>[];
|
||||
});
|
||||
|
||||
@@ -203,8 +206,12 @@ void main() {
|
||||
notificationPermissionProvider.overrideWith(
|
||||
(ref) => NotificationPermission(isAndroid: false),
|
||||
),
|
||||
multiImagePickerProvider
|
||||
.overrideWith((ref) => (context) async => galleryPaths),
|
||||
multiImagePickerProvider.overrideWith(
|
||||
(ref) => (context, {required accountId, required albumId}) async {
|
||||
pickerScopes.add((accountId, albumId));
|
||||
return galleryPaths;
|
||||
},
|
||||
),
|
||||
],
|
||||
child: MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
@@ -410,6 +417,8 @@ void main() {
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
expect(find.text('Added 2 photo(s) to the upload queue'), findsOneWidget);
|
||||
// 方案 A 接线:拦截判定范围随调用点传入(连拍目标账号+相册)。
|
||||
expect(pickerScopes, [('alice', 'alb-1')]);
|
||||
expect(await store.listByAccount('alice'), hasLength(2));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user