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 ability to handle errors #637

Open
f3dm76 opened this issue Nov 1, 2024 · 3 comments
Open

Add ability to handle errors #637

f3dm76 opened this issue Nov 1, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@f3dm76
Copy link

f3dm76 commented Nov 1, 2024

What are you trying to achieve?

I'm displaying the chat like this:
ChatChannelView(viewFactory: viewFactory, channelController: controller)
Sometimes it just shows a loading indicator indefinitely, I guess there was some error inside ChatChannelController, I'd like to receive that error, display it for the user, and handle it somehow

If possible, how can you achieve this currently?

It's doable through ChatChannelVC.didFinishSynchronizing(error:), but I didn't find a way in SwiftUI

What would be the better way?

For example ChatChannelController can have an error publisher. Or ChatChannelView can have a closure parameter to handle errors.

GetStream Chat version: 4.62.0
GetStream Chat frameworks: StreamChat, StreamChatUI
iOS version: 18.0
Swift version: 6.0
Xcode version: 16.0
Device: sim iPhone 16 pro max

@nuno-vieira
Copy link
Member

nuno-vieira commented Nov 6, 2024

Hi @f3dm76,

We do show an error if synchronize fails, like in the picture below. If there is an error it will be available in the ChatChannelListViewModel.channelAlertType == .error

Also, make sure you update to the last version.

@nuno-vieira nuno-vieira added the question Further information is requested label Nov 6, 2024
@f3dm76
Copy link
Author

f3dm76 commented Nov 8, 2024

Hey @nuno-vieira, thank you for your answer.
Sorry, but what is a ChatChannelListViewModel? I mean how do I get it from @Injected(\.chatClient)? I only have ChatChannelController. Your screenshot shows chats list, how did you get the error while still being there?

My situation is this - I navigate to chat details screen:

struct MessagesChatView: View {
    var controller: ChatChannelController
    var body: some View {
        // SC chat view which sometimes shows an endless loading spinner and nothing else
         ChatChannelView(viewFactory: viewFactory, channelController: controller) 
    }
}

asking for chat controller like this chatClient.channelController(for: ...). Then sometimes (very rarely) I see an endless loading spinner in chat details, and I need to be able to get the error (or I don't know what - I just see the spinner from inside the SC library) and show the error while inside the chat details.

I'd expect smth like:

var controller: ChatChannelController
var body: some View {
     ChatChannelView(viewFactory: viewFactory, channelController: controller)
          .onReceive(controller.errorPublisher) {
                   // show the error, suggest to navigate back or ideally retry
          }
}

@nuno-vieira
Copy link
Member

Hi @f3dm76,

My bad I got confused with the Channel List.

Indeed, it seems on SwiftUI this is missing in the channel view.

We will add this to our backlog and we will let you know once we pick this one up 👍

Best,
Nuno

@nuno-vieira nuno-vieira added enhancement New feature or request and removed question Further information is requested labels Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants