In cometchat i have to show list of selected Users instead of all the users

35 Views Asked by At

In cometchat

In cometchat i have to show list of selected Users in left sidebar of UI instead of all the users.

Anyone can help me out?

let limit = 5; let usersRequest = new CometChat.UsersRequestBuilder() .setLimit(limit) .setUIDs(UIDs);

      console.log(usersRequest)
      setSelectedUsers(new UsersConfiguration({usersRequestBuilder: usersRequest}));

Getting Error Like this { "name": "TypeError", "message": "Cannot read properties of undefined (reading 'getAdminHost')" }

1

There are 1 best solutions below

1
Gordon Westerman On

This happened to me, after I removed a line of code that would have led to ChatComet being initialized.

From the docs for CometChat's JavaScript SDK (v4):

You need to call init() before calling any other method from CometChat. We suggest you call the init() method on app startup, preferably in the index.js file.

let appID = "APP_ID";
let region = "APP_REGION";
let appSetting = new CometChat.AppSettingsBuilder()
                    .subscribePresenceForAllUsers()
                    .setRegion(region)
                    .autoEstablishSocketConnection(true)
                    .build();
CometChat.init(appID, appSetting).then(
  () => {
    console.log("Initialization completed successfully");
  }, error => {
    console.log("Initialization failed with error:", error);
  }
);

Make sure this happens in the right order and you should be fine.