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

Add missing property redirected to VisitResponse #24

Closed
wants to merge 2 commits into from

Conversation

olivaresf
Copy link
Member

Turbo-iOS PR: hotwired/turbo-ios#225

When a redirection with a responseHTML would happen (e.g. a form submission), Turbo Native receives something like the following:

← visitProposed [
    "location": http://localhost:45678/submit_redirected, 
    "timestamp": 1725557992593, 
    "options": {
        action = replace;
        response =     {
            redirected = 1;
            responseHTML = "{HTML with flash notice}";
            statusCode = 200;
        };
        shouldCacheSnapshot = 0;
    }
]

This usually gets turned into a JavaScript visit and then handed over to the bridge, which begins the visit by calling visitLocationWithOptionsAndRestorationIdentifier.

However, when transforming this proposal JS -> Swift (for processing) and back to JS (for bridge consumption), visitProposed["options"]["response"]["redirected"] was being lost. This caused responseHTML to be ignored and a replace visit to be proposed instead.

By adding redirected to VisitResponse the behavior is now correct.

@olivaresf olivaresf requested a review from jayohms September 19, 2024 23:10
* main: (44 commits)
  Remove not needed parentheses.
  Move the configuration of the custom user agent prefix to the AppDelegate.
  Register the WebView instance with the bridge when each WKWebView instance is created
  Swap order of parameters
  Fine tune custom user agent setting
  Set session's path config from the global path config.
  Consolidate all global config by moving it in app delegate.
  Add utility func to load path config to the Hotwire enum.
  Move `matchQueryStrings` to `PathConfiguration`.
  Move `registerBridgeComponents` to `AppDelegate`.
  Move comment out of if statements.
  Update documentation for the default navigation controller.
  Document `HotwireNavigationController`.
  Revert "Temporarily configure app to have a tab bar as the root view."
  Remove tab switched check from session.
  Extract `HotwireNavigationController` in its own file.
  Handle tab switched in session.
  Use `viewIsAppearing` instead of `viewWillAppear` to have the correct call sequence.
  Make AppearReason a property on the Visitable protocol.
  Temporarily configure app to have a tab bar as the root view.
  ...
@jayohms
Copy link
Contributor

jayohms commented Dec 16, 2024

Closing this in favor of: #60

@jayohms jayohms closed this Dec 16, 2024
@jayohms jayohms deleted the add-redirected-to-visit-response branch December 16, 2024 22:48
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.

2 participants