Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist visit options if a response is present #155

Merged
merged 5 commits into from
Mar 22, 2024

Conversation

olivaresf
Copy link
Member

@olivaresf olivaresf commented Nov 6, 2023

Persist visit options for when a response HTML is provided. I've seen this fix an issue where the flash alert would not be displayed, if provided via visit options.

return options
} else if let unhandledVisitOptions {
/// Next visit is happening. Use the previous visit options.
self.unhandledVisitOptions = nil
Copy link
Member Author

Choose a reason for hiding this comment

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

Make sure URLs match between visit options

Copy link
Member

Choose a reason for hiding this comment

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

Has this been resolved?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not exactly. Would we keep the visit options around indefinitely until the next visit or should the next visit use them? If the former, URL matching makes sense. Otherwise, this implementation works for our purposes.

What do you think? Sorry to say I'm still trying to understand when to expect a responseHTML and I also don't think Android is doing it 🤔.

…s-response

* origin/main:
  Fix obious wrong boolean expression (#159)
  Replace Quick/Nimble with XCTest (#139)
@seanpdoyle
Copy link

@olivaresf is this work related to #136 (comment)? What kind of community support could help push this forward?

@olivaresf
Copy link
Member Author

Coincidentally, my plan is to test this PR thoroughly sometime next week. Let me test this and #160 as I believe we're both sort of circling around the same issue and then I'll come back to you.

@joemasilotti
Copy link
Member

Hey @olivaresf, we'd love to get this wrapped up as it also fixes #186.

Is all that's left adding tests and addressing the comment?

I'm no Android expert, but @jayohms called out that the Android library handles this in a separate view model to keep track of the visit options in between requests. It's then used here.

I wonder if there's an approach that might work better on iOS following that model? If you've already explored that then disregard, just wanted to explore a closer implementation between the two libraries.

@olivaresf
Copy link
Member Author

Thanks for your patience! Still trying to come back to this, but I've had other priorities.

Is all that's left adding tests and addressing the comment?

Yep. If you can help me with that, I'd appreciate it. If not, I'll make some time tomorrow to test this out.

…s-response

* origin/main:
  Fix when snapshot cache is cleared (#185)
  Stale content (#184)
  Note feature parity in CONTRIBUTING doc
  Provide backwards compatibility support for Turbo 7.x and Turbolinks 5
  Support visit.isPageRefresh and avoid displaying the activity indicator and screenshots when the page is refreshing
  Support Turbo 8 same-page refreshes and include debug logging
  rename loadrRequest to load (#141)
  Add CONTRIBUTING.md (#90)
  Update README window.Turbo reference (#68)

# Conflicts:
#	Source/Session/Session.swift
@olivaresf olivaresf marked this pull request as ready for review March 1, 2024 17:57
@olivaresf
Copy link
Member Author

I've added a unit test for this behavior. As far as I can tell, I'm mimicking Android's behavior:

  • If visit options with a responseHTML are provided during a Turbo visit, we save the options.
  • During the next visit, saved options are given to the new visit and then saved options are deleted so they cannot be reused.

I've tested this on Basecamp and it works as I expected. Let me know if there's anything else needed.

Copy link
Collaborator

@jayohms jayohms left a comment

Choose a reason for hiding this comment

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

This looks good to me 👍. I looked at the Android side and we're not validating the url between visits for the response, so in practice I don't see this as an issue.

@jayohms jayohms merged commit dabd33d into main Mar 22, 2024
1 check passed
@jayohms jayohms deleted the preserve-visit-options-response branch March 22, 2024 20:17
joemasilotti added a commit to hotwired/hotwire-native-ios that referenced this pull request Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants