liveview-native / liveview-client-swiftui

MIT License
365 stars 32 forks source link

[Bug]: Navigation events don't trigger the disconnected mount or re-establish the socket connection #1228

Open BrooklinJazz opened 8 months ago

BrooklinJazz commented 8 months ago

What happened?

The navigation events currently disconnect the LiveViewCoordinator which manages a channel, but not the LiveSessionCoordinator. which manages a socket.

This means navigation functions such as redirect/2 or push_navigate/2 don't trigger the disconnected mount as they would normally be expected to.

In addition to not matching the expected behaviour, I'm concerned this could lead to security issues. For example, I'd like to explore if the :on_mount for a live_session group is triggered or not as normally using push_navigate/2 between different live_sessions would re-establish a socket connection. However this needs further exploration to determine if it's an issue or not.

  live_session :admin, on_mount: MyAppWeb.AdminLiveAuth do
    live "/admin", AdminDashboardLive, :index
    live "/admin/posts", AdminPostLive, :index
  end

Library Version

main

Xcode Version

main

Swift Version

main

On which device or simulator are you running into the problem?

iPhone

Target Device Operating System Version

NA

Relevant log output

No response

carson-katri commented 8 months ago

I tested cross-live_session navigation and it works with the changes from #1226. However, unlike the web this should only be done from the root of the app with replace: true. If done from a nested navigation route, the app will attempt to reconnect to the initial URL instead of the new one. Anything more complex gets tricky, because at that point you would probably need multiple LiveSessionCoordinators to manage the different sockets within a single navigation stack.

carson-katri commented 8 months ago

We could wait on aligning this until liveview-native-core is handling navigation.

AZholtkevych commented 5 months ago

Acxcording to discussion with @carson-katri we have to implement this in core. FYI @simlay @bcardarella