Skip to content

Fix: multi-language captions not saved on upload (#6938) - #6946

Open
r-thak wants to merge 1 commit into
commons-app:mainfrom
r-thak:fix/multi-language-captions-not-saved
Open

Fix: multi-language captions not saved on upload (#6938)#6946
r-thak wants to merge 1 commit into
commons-app:mainfrom
r-thak:fix/multi-language-captions-not-saved

Conversation

@r-thak

@r-thak r-thak commented Aug 15, 2026

Copy link
Copy Markdown

Description

Fixes #6938 — captions added in additional languages during upload were dropped, so only the default-language caption made it onto Commons.

Root cause

In the media detail step, language rows added via the "+" button only ever lived in UploadMediaDetailAdapter's own copy; nothing wrote them back into the UploadItem that the upload pipeline reads from. presenter.setUploadMediaDetails was only ever called on process-death restore, so refreshing/renavigating wiped the extra rows, leaving only the primary-language caption.

Fix

  • UploadMediaDetailAdapter.EventListener gets a new onMediaDetailsChanged() callback, fired whenever a row is added or removed.
  • UploadMediaDetailFragment implements it by persisting the adapter's current list into the UploadItem via the presenter, so extra language rows survive navigation and screen rebuilds.
  • DescriptionEditActivity (the other EventListener implementer, used to edit captions on already-uploaded media) gets a no-op override — it already reads the adapter directly on submit, so it isn't affected by this bug.
  • removeDescription also fires the callback, not just addDescription: without it, removing a row leaves it stale in the persisted UploadItem, and it would still get uploaded.

Testing

  • Reproduced on main: added an en and a de caption, went Next → Previous, and the de row disappeared (check screencast)
  • Verified on this branch: same steps, both captions survive (check screencast)
  • I added a unit test (setUploadMediaDetailsOnlyUpdatesTargetedItemInMultiImageUpload) that asserts setUploadMediaDetails only touches the targeted UploadItem's index and leaves others alone.
  • Ran UploadMediaDetailAdapterUnitTest, UploadMediaDetailFragmentUnitTest, and UploadMediaPresenterTest (53/53 passing).

Screenshots/recordings:

1_before_screencast_bug.mp4
2_before_captions_entered 3_after_captions_entered
4_after_screencast_fixed.mp4

Language rows added via the "+" button in the media detail step only
ever lived in UploadMediaDetailAdapter's own copy of the list. Nothing
wrote them back into the UploadItem that the upload pipeline actually
reads, so as soon as the screen was repopulated (e.g. navigating to
another step and back), the extra rows were silently dropped and only
the default-language caption made it into the uploaded file.

Add an EventListener.onMediaDetailsChanged() callback fired whenever a
row is added or removed, and have UploadMediaDetailFragment persist the
adapter's current list into the UploadItem immediately.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-language captions not saved

1 participant