Fix: multi-language captions not saved on upload (#6938) - #6946
Open
r-thak wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theUploadItemthat the upload pipeline reads from.presenter.setUploadMediaDetailswas only ever called on process-death restore, so refreshing/renavigating wiped the extra rows, leaving only the primary-language caption.Fix
UploadMediaDetailAdapter.EventListenergets a newonMediaDetailsChanged()callback, fired whenever a row is added or removed.UploadMediaDetailFragmentimplements it by persisting the adapter's current list into theUploadItemvia the presenter, so extra language rows survive navigation and screen rebuilds.DescriptionEditActivity(the otherEventListenerimplementer, 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.removeDescriptionalso fires the callback, not justaddDescription: without it, removing a row leaves it stale in the persistedUploadItem, and it would still get uploaded.Testing
main: added anenand adecaption, went Next → Previous, and thederow disappeared (check screencast)setUploadMediaDetailsOnlyUpdatesTargetedItemInMultiImageUpload) that assertssetUploadMediaDetailsonly touches the targetedUploadItem's index and leaves others alone.UploadMediaDetailAdapterUnitTest,UploadMediaDetailFragmentUnitTest, andUploadMediaPresenterTest(53/53 passing).Screenshots/recordings:
1_before_screencast_bug.mp4
4_after_screencast_fixed.mp4