Skip to content

Conversation

laevandus
Copy link
Contributor

@laevandus laevandus commented Sep 23, 2024

🔗 Issue Link

Resolves: PBE-6081

🎯 Goal

  • Fix an issue where embedding the ChatChannelListView breaks its navigation after the embedded view reloads its body
  • Added documentation to the ChatChannelListView.init

🛠 Implementation

The default onTapHandler captures the view model instance created within the view, not the one stored in the @StateObject property. When view reloads, onTapHandler captures the incorrect instance.

🧪 Testing

  1. Open DemoAppSwiftUIApp.swift
  2. Replace case .loggedIn: implementation with:
NavigationView {
    VStack {
        Button(!isBroken ? "Break" : "Broken") {
            isBroken.toggle()
        }
        ChatChannelListView(
            viewFactory: DemoAppFactory.shared,
            channelListController: channelListController,
            embedInNavigationView: false
        )
    }
}

and add
@State private var isBroken = false
to the DemoAppSwiftUIApp type
3. Launch the demo app
4. Tap on any of the items and verify that the tapped channel is opened
5. Navigate back to the channel list, tap on the "Break" button and verify that navigation is still possible.

☑️ Checklist

  • I have signed the Stream CLA (required)
  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Affected documentation updated (docusaurus, tutorial, CMS (task created)

self.onItemTap = onItemTap
} else {
self.onItemTap = { channel in
channelListVM.selectedChannel = channel.channelSelectionInfo
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note how it does not capture the self.viewModel instance.

@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Sep 23, 2024

SDK Size

title develop branch diff status
StreamChatSwiftUI 7.1 MB 7.11 MB +1 KB 🟢

@laevandus laevandus force-pushed the fix/embedded-channel-list-navigation branch from 2db4e85 to 514fdac Compare September 23, 2024 11:26
@laevandus laevandus enabled auto-merge (squash) September 23, 2024 11:27
Copy link

@laevandus laevandus merged commit f70197e into develop Sep 23, 2024
11 checks passed
@laevandus laevandus deleted the fix/embedded-channel-list-navigation branch September 23, 2024 12:12
@Stream-SDK-Bot Stream-SDK-Bot mentioned this pull request Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants