···327 setGalleries(galleries);
328 return galleries;
329 }
330+331+ /// Updates alt text for multiple photos by calling apiService.updatePhotos, then updates the gallery cache state manually.
332+ /// [galleryUri]: The URI of the gallery containing the photos.
333+ /// [altUpdates]: List of maps with keys: photoUri, alt (and optionally aspectRatio, createdAt, photo).
334+ Future<bool> updatePhotoAltTexts({
335+ required String galleryUri,
336+ required List<Map<String, dynamic>> altUpdates,
337+ }) async {
338+ final success = await apiService.updatePhotos(altUpdates);
339+ if (!success) return false;
340+341+ // Update the gallery photos' alt text in the cache manually
342+ final gallery = state[galleryUri];
343+ if (gallery == null) return false;
344+345+ // Build a map of photoUri to new alt text
346+ final altMap = {for (final update in altUpdates) update['photoUri'] as String: update['alt']};
347+348+ final updatedPhotos = gallery.items.map((photo) {
349+ final newAlt = altMap[photo.uri];
350+ if (newAlt != null) {
351+ return photo.copyWith(alt: newAlt);
352+ }
353+ return photo;
354+ }).toList();
355+356+ final updatedGallery = gallery.copyWith(items: updatedPhotos);
357+ state = {...state, galleryUri: updatedGallery};
358+ return true;
359+ }
360}