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

Migrate Turbo Native helpers to Hotwire Native #691

Merged
merged 1 commit into from
Oct 5, 2024

Conversation

joemasilotti
Copy link
Member

This PR renames the turbo_native_app? helper to hotwire_native_app? and changes the user agent check to look for "Hotwire Native".

It is backwards compatible with existing Turbo Native apps by aliasing the turbo_native_app? helper and also checking for "Turbo Native" in the user agent.

@dhh dhh merged commit 567520f into hotwired:main Oct 5, 2024
15 checks passed
@joemasilotti joemasilotti deleted the hotwire-native-helpers branch October 5, 2024 01:39
module Turbo::Native::Navigation
extend ActiveSupport::Concern

included do
helper_method :turbo_native_app?
helper_method :hotwire_native_app?, :turbo_native_app?

Choose a reason for hiding this comment

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

It breaks the following patch for Devise:

#507 (comment)

Quick fix for anyone stumbling across:

class TurboFailureApp < Devise::FailureApp
  # Compatibility for Turbo::Native::Navigation
  class << self
    def helper_method(*names)
    end
  end

  include Turbo::Native::Navigation

  # Turbo Native requests that require authentication should return 401s to trigger the login modal
  def http_auth?
    turbo_native_app? || super
  end
end

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.

3 participants