Do we have profile edit mutation? See ../hackerspub
- User
Do we have profile edit mutation? See ../hackerspub
Assistant
Yes — there's an
updateAccountmutation in hackerspub.Location:
../hackerspub/graphql/account.ts:496-602(schema:graphql/schema.graphql:1424-1443)Signature:
graphqlmutation updateAccount(input: UpdateAccountInput!): UpdateAccountPayload!UpdateAccountInputeditable fields:id(required),username,name,bioavatarUrl— server fetches image from URL (JPEG/PNG/GIF/WebP); no separate upload mutationlocales,links([{name, url}])- Toggles:
hideFromInvitationTree,hideForeignLanguages,preferAiSummary - Defaults:
defaultNoteVisibility,defaultShareVisibility
Notes:
- No header/banner field.
- No separate avatar upload mutation — you pass a URL that the server fetches.
- User
How we handle avatar upload then?
Assistant
Here's the avatar upload flow:
No direct file upload endpoint —
updateAccount.avatarUrlaccepts aURL, and on the web client that URL is just adata:URL.Web flow (
web-next/src/routes/[handle]/settings/index.tsx:200-324):- User picks file via dropzone (5 MB limit)
- Cropper.js crops in a dialog
canvas.toDataURL()→data:image/...;base64,...- Data URL passed directly as
avatarUrlinupdateAccount - Server fetches the data URL and stores it (validates MIME, transforms via
transformAvatar())
For Android, you'd do the same:
- Pick image → crop → encode as
data:image/jpeg;base64,<base64>→ pass asavatarUrlinupdateAccount.
Note: there's a separate
uploadMediamutation (graphql/post.ts:1341-1398) for post attachments which also takes a URL (data URL works) and returns a stored URL — but for avatars it's unused; the settings page just passes the data URL straight toupdateAccount.- User
Okay, go with it
Assistant
Let me look at existing reference patterns for similar screens (compose, drafts) and check image-picking helpers.
Assistant
Scope confirmed: name + bio + avatar + links, entry point on own profile header. Starting with task #1.
Assistant
Now I'll add the GraphQL operations.
Assistant
Task 1 done. Apollo generated types are good —
UpdateAccountInput.avatarUrl: Optional<Any?>accepts a String (same pattern used inCreateNoteMutation.content: Any).Assistant
Now adding the domain model and repository methods.
Assistant
Now the repository methods.
Assistant
Compile clean. Commit task #2.
Assistant
Now the EditProfileViewModel. Let me first examine similar patterns in the codebase (ComposeArticleViewModel for a form-with-save example).
Assistant
Good. Commit #3.
Assistant
Now the EditProfileScreen UI. Let me look at LargeTitleHeader and strings.
Assistant
Now the screen.
Assistant
Now wire the picker into the screen.
Assistant
Commit #5.
Assistant
Now navigation wiring + edit button on profile.
Assistant
Now find the Profile route composable and add navigation params, and add the EditProfile composable entry.
Assistant
Add the import.
Assistant
Now add the Edit button to ProfileScreen and plumb the callback through.
Assistant
Now pass the callback to ProfileHeader and render the Edit button when isViewer.
Assistant
Now add the Edit button inside the
if (!isViewer)block's complement — whenisVieweris true.Assistant
Let me also wire a refresh-on-return signal so the profile shows the updated data after save.
Assistant
Now add the
refreshSignal/onRefreshConsumedplumbing in ProfileScreen.Assistant
Strings are already in. Now ViewModel test.
Assistant
Now write the EditProfileViewModel test following this pattern.
Assistant
All tests pass. Commit #7.
Assistant
All seven commits landed on
feature/profile-edit. Summary of what shipped:- GraphQL:
UpdateAccountmutation +EditAccountquery (reads Markdown bio fromviewer) - Repository:
getEditableAccount()(NetworkOnly) andupdateAccount(...);avatarUrlpassed through as-is - ViewModel:
EditProfileViewModelwith StateFlow state +EditProfileEvent.Savedvia Channel (§6.3) - UI:
EditProfileScreenwith name, bio, links (add/remove), avatar preview - Avatar:
PickVisualMedia→ downscale to 1024px → JPEG q85 → base64 →data:image/jpeg;base64,... - Navigation:
DetailScreen.EditProfileroute, Edit button on profile header whenisViewer, savedStateHandle signal triggersrefresh()on return - Tests: 10 ViewModel tests covering load/edit/save paths; full test suite passes
Caveats I didn't get to:
- GraphQL: