refactor(import): run every import source through one flow - #81
Merged
Merged
Conversation
Nine import sources each had their own screen and view model, and the flow behind them was the same in all nine: pick an input, preview it, choose what to bring across, submit, poll the job, report. They now share one. - ImportSources.kt has an ImportSource entry per source holding everything that differs: what the user supplies (a file, an encrypted file and its passphrase, or a token), how the preview is fetched and read, the fixed options fields, and the few real quirks, such as PluralKit's live pull going to the credential endpoint and a Sheaf complete-backup zip submitting under its own source. - ImportViewModel and ImportScreen run the flow for whichever source the route names. - ImportSourcePickerScreen replaces the nine rows in Settings > Data with one "Import data" row and a list to choose from. Adding a source is now an entry in the registry rather than two new files and a new route. Onboarding's Simply Plural shortcut goes through the same flow. **One options builder.** The nine hand-written request builders become buildOptionsJson, and the tests pin what each of them had to get right on its own: a category the export did not populate is still sent at its default, because the backend rejects unknown fields but expects the known ones; the sources that send an explicit null member_ids still do and the others still omit it; a narrowed selection sends its ids; and fixed fields go out alongside the toggles.
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.
Nine import sources each had their own screen and view model, and the flow behind them was the same in all nine: pick an input, preview it, choose what to bring across, submit, poll the job, report. They now share one. About 4,400 lines out, 1,300 in.
How it fits together
ImportSources.kthas anImportSourceentry per source holding everything that differs: what the user supplies (a file, an encrypted file and its passphrase, or a token), how the preview is fetched and read, the fixed options fields, and the few real quirks, such as PluralKit's live pull going to the credential endpoint and a Sheaf complete-backup zip submitting under its own source.ImportViewModelandImportScreenrun the flow for whichever source the route names (settings/import/run/{source}).ImportSourcePickerScreenreplaces the nine rows in Settings > Data with one "Import data" row and a list to choose from.Adding a source is now an entry in the registry rather than two new files and a new route. Onboarding's Simply Plural shortcut goes through the same flow.
One options builder
The nine hand-written request builders become
buildOptionsJson. The tests pin what each of them had to get right on its own:"member_ids": null(Prism, PluralSpace, Ampersand) still do, and the others still omit it;conflict_strategygo out alongside the toggles.Checked
ImportBodyTest, extended with the builder cases above, and the full unit suite on this branch.assembleOpenDebugandassemblePlayDebug.SheafApp.ktandSettingsCategoryScreens.ktlike feat(sharing): manage public profiles and share links from the phone #78 and feat(settings): fold the Safety category into System #79 do, in different places; it merges cleanly with each of them, in either order.