Pre-set profile to active profile when creating a new link#390
Pre-set profile to active profile when creating a new link#390yogeshpaliyal merged 4 commits intomasterfrom
Conversation
Co-authored-by: yogeshpaliyal <9381846+yogeshpaliyal@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where creating a new link defaulted to profile ID 1L instead of the user's currently active profile. The root cause was twofold: createDeeprObject() hardcoded profileId = 1L, and AddLinkScreen attempted to use a fallback to currentProfile?.id within a remember(selectedLink) block, which captured the value before the StateFlow could emit, resulting in null and falling back to 1L.
Changes:
- Collect
currentProfilefrom ViewModel inHome.ktand pass the current profile ID (or fallback to1L) to all threecreateDeeprObject()call sites - Simplify
AddLinkScreen.ktto directly useselectedLink.profileIdwithout the timing-sensitive fallback logic
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| app/src/main/java/com/yogeshpaliyal/deepr/ui/screens/home/Home.kt | Collects currentProfile StateFlow and passes currentProfile?.id ?: 1L to all three createDeeprObject() call sites (FAB, clipboard banner, shared text handler) |
| app/src/main/java/com/yogeshpaliyal/deepr/ui/screens/addlink/AddLinkScreen.kt | Removes unnecessary currentProfile collection and simplifies profile ID initialization to directly use selectedLink.profileId since it's now correctly set at navigation time |
🧪 Integrated Test ResultsThe integrated UI tests have completed. View full test results: Test Run #22259888771 Test reports are available in the artifacts section of the workflow run. |
📱 APK Build Complete!Your debug APK has been built successfully and is ready for testing. 📥 Download APKNote: Click the link above, scroll down to the "Artifacts" section, and download the Retention: This artifact will be available for 3 days. |
🧪 Integrated Test ResultsThe integrated UI tests have completed. View full test results: Test Run #22259978438 Test reports are available in the artifacts section of the workflow run. |
When creating a new link, the profile dropdown defaulted to profile ID
1Lregardless of which profile the user was currently in.Root cause: Two compounding issues:
createDeeprObject()hardcodedprofileId = 1LAddLinkScreentried to fall back tocurrentProfile?.idinside aremember(selectedLink)block, which captures the value at first composition — before theStateFlowemits, socurrentProfilewasnulland the fallback to1LappliedChanges:
Home.kt: CollectcurrentProfilefrom the ViewModel and passcurrentProfile?.id ?: 1Lto all threecreateDeeprObject()call sites (FAB button, clipboard banner, shared text handler)AddLinkScreen.kt: SimplifyselectedProfileIdinitialization toselectedLink.profileIddirectly — the timing-sensitivecurrentProfilefallback is no longer needed since the correct profile ID is now passed at navigation timeWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dl.google.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.13-bin/5xuhj0ry160q40clulazy9h7d/gradle-8.13/lib/gradle-daemon-main-8.13.jar(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.