unindexImageHash function

Future<void> unindexImageHash({
  1. required String hash,
  2. String? scope,
})

Implementation

Future<void> unindexImageHash({
  required String hash,
  String? scope,
}) async {
  final h = hash.trim();
  if (h.isEmpty) return;

  try {
    await _ensureCollectionDirExists(IMAGE_INDEX_COLLECTION);
  } catch (_) {}

  final s = _canonicalizeScope((scope ?? '').trim());
  final legacyScope = _legacyScopeForCanonical(s);
  final scopes = <String>{'', s};
  if (legacyScope != s) scopes.add(legacyScope);

  for (final scopeCandidate in scopes) {
    try {
      final id = _imageIndexDocId(h, scope: scopeCandidate);
      await imageIndexCollection.doc(id).delete();
    } catch (_) {}
  }
}