Skip to content

Generate share links for CYOA tools (GT-3080) - #4588

Open
tjohnson009 wants to merge 1 commit into
developfrom
GT-3080-CYOA-Share-Links
Open

tjohnson009 wants to merge 1 commit into
developfrom
GT-3080-CYOA-Share-Links

Conversation

@tjohnson009

Copy link
Copy Markdown
Contributor

Summary

CYOA tools currently have no share link at all — CyoaActivity inherits the empty shareLinkUriLiveData from BaseToolActivity, so the share button never appears. This adds outgoing share link generation matching the knowgod.com URL pattern the incoming deep link parser (CyoaDeepLink) already supports:

https://knowgod.com/{locale}/tool/v2/{tool}/{page}?icid=gtshare

Changes

  • Track the currently displayed page fragment in pageFragmentLiveData, updated via FragmentLifecycleCallbacks (covers forward navigation, back navigation, and page dismissal)
  • Override shareLinkUriLiveData to combine the active manifest with the current page, so the link updates on both language changes and page navigation
  • The share menu item and QR code action appear automatically via the existing BaseToolActivity wiring once the link is non-null

The {position} path segment supported by CyoaDeepLink for card/page-collection pages is intentionally not included — the ticket's example URL omits it, and it can be added as a follow-up if needed.

Tests

  • Share link contains the current page id
  • Link updates when navigating forward and back
  • Generated links round-trip through CyoaDeepLink.parseKnowGodDeepLink (same tool/page/locale)
  • No link before a manifest is loaded

🎫 GT-3080

🤖 Generated with Claude Code

Track the currently displayed page fragment via fragment lifecycle
callbacks and combine it with the active manifest to build share links
matching the knowgod.com URL pattern already supported by CyoaDeepLink:
https://knowgod.com/{locale}/tool/v2/{tool}/{page}

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tjohnson009
tjohnson009 requested a review from a team September 4, 2026 18:46
@codecov

codecov Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.25%. Comparing base (35ed24f) to head (b88383f).
⚠️ Report is 15 commits behind head on develop.

Files with missing lines Patch % Lines
...tlin/org/cru/godtools/tool/cyoa/ui/CyoaActivity.kt 81.81% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4588      +/-   ##
===========================================
+ Coverage    53.19%   53.25%   +0.05%     
===========================================
  Files          440      440              
  Lines        11585    11607      +22     
  Branches      1960     1967       +7     
===========================================
+ Hits          6163     6181      +18     
  Misses        4839     4839              
- Partials       583      587       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

val tool = code ?: return null
val locale = locale ?: return null
return URI_SHARE_BASE.buildUpon()
.appendEncodedPath(locale.toString().lowercase(Locale.ENGLISH))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

locale.toString() might be wrong for locales with regions, if it's a java Locale object you will want to use locale.toLanguageTag(), if it's the fluidsonic Locale object, I'm not totally sure what format it uses for .toString()

Comment on lines +233 to +238
private val pageFragmentLiveData = MutableLiveData<CyoaPageFragment<*, *>?>(null)

private fun updatePageFragmentLiveData() {
val fragment = supportFragmentManager.primaryNavigationFragment as? CyoaPageFragment<*, *>
if (pageFragmentLiveData.value !== fragment) pageFragmentLiveData.value = fragment
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't be storing the fragment in a LiveData. I don't think your current implementation would leak anything, but storing an active fragment like this has potential to leak the fragment if it's not handled carefully.

You should probably just store what page the fragment is for

Comment on lines +216 to +219
.appendPath("tool")
.appendPath("v2")
.appendPath(tool)
.apply { page?.let { appendPath(it.id) } }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you are properly handling page collection pages here or card collection pages

@frett

frett commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

This might need to be put on hold, I posted a message in the godtools channel about the web not supporting page collection pages, which means that those pages would be shared incorrectly.

@tjohnson009

Copy link
Copy Markdown
Contributor Author

Going to wait in this until further notice

@frett frett added the onhold label Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants