GetStream / stream-chat-swift

💬 iOS Chat SDK in Swift - Build your own app chat experience for iOS using the official Stream Chat API
https://getstream.io/chat/sdk/ios/
Other
856 stars 209 forks source link

Default delete action for channel is looking up wrong ID #2607

Closed mkhandium closed 1 year ago

mkhandium commented 1 year ago

What did you do?

Swiped left on a channel. Tapped the delete button.

What did you expect to happen?

Delete the channel.

What happened instead?

Got an error with the message


{
  "code" : 16,
  "message" : "DeleteChannel failed with error: \"Can't find channel with id messaging:3601A866-9E03-4624-8959-588CFDF84A9C\"",
  "more_info" : "https:\/\/getstream.io\/chat\/docs\/api_errors_response",
  "details" : [

  ],
  "StatusCode" : 404,
  "duration" : "0.00ms"
})```
This channel was created with type `.livestream` so I am not sure why the id has `messaging` in it.

## GetStream Environment
**GetStream Chat version:** Latest main
**GetStream Chat frameworks:** StreamChat, StreamChatUI
**iOS version:** 16.4
**Swift version:** 5
**Xcode version:** 14.3
**Device:** iPhone 14 Pro Simulator

## Additional context
The UUID string here is correct, but the appended type to the id is wrong when deleting a channel with the default delete action
mkhandium commented 1 year ago

FYI Deleting a conversation uses the proper cid if you access it from the more menu, instead of using the trailing delete action button.

mkhandium commented 1 year ago

Found the related code in the ChatChannelListViewModel


        let controller = chatClient.channelController(
            for: .init(type: .messaging, id: channel.cid.id)
        )

        controller.deleteChannel { [weak self] error in
            if error != nil {
                // handle error
                self?.channelAlertType = .error
            }
        }
    }```

    The type is hardcoded to be `messaging` instead of the channel's actual `ChannelType`
mkhandium commented 1 year ago

Going to close this issue because this is an issue with the swift-ui sdk not the swift sdk.