cometchat/cometchat-uikit-ios

LoggedInUser exists as a global static variable

Closed this issue · 3 comments

Describe the problem

struct LoggedInUser {
static let uid = CometChat.getLoggedInUser()?.uid ?? ""
static let name = CometChat.getLoggedInUser()?.name ?? ""
}

LoggedInUser is behaving like a global static variable. After logged out from comet chat, the struct persists and the value of uid and name still refers to the last loggedInUser.

This LoggedInUser is being referred in various UI Screens and components.

What was the expected behavior?

It is supposed to be properly referring to the loggedIn user and when its logged out, it should be cleared.

Reproduction

  1. Calling CometChat.Logout
  2. LoggedInUser still refers to the previous user
  3. Calling CometChat.login
  4. LoggedInUser still refers to the previous user
  5. Killing the app resets the reference

Environment

Please provide the following:

  • 2.1.0
  • CometChatPro

Hello @JohnKuan,

Thanks for reporting. We will fix this in the next release. You can override and set the new user's uid after login method.

Hello @JohnKuan,

I hope your issue is resolved with the solution mentioned above. Closing this issue, if you're still facing the same then let us know.

Hi @pushpsenairekar2911,

Thanks, it was resolved.