@ermis-network/ermis-chat-sdk 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3547,17 +3547,24 @@ var ErmisChat = class _ErmisChat {
3547
3547
  async unpinChannel(channelType, channelId) {
3548
3548
  return await this.post(this.baseURL + `/channels/${channelType}/${channelId}/unpin`);
3549
3549
  }
3550
- channel(channelType, channelID, custom = {}) {
3550
+ channel(channelType, channelIDOrCustom, custom) {
3551
3551
  if (!this.userID) {
3552
3552
  throw Error("Call connectUser before creating a channel");
3553
3553
  }
3554
3554
  if (~channelType.indexOf(":")) {
3555
3555
  throw Error(`Invalid channel group ${channelType}, can't contain the : character`);
3556
3556
  }
3557
- return this.getChannelById(channelType, channelID, custom);
3557
+ let channelID = void 0;
3558
+ let customData = custom || {};
3559
+ if (typeof channelIDOrCustom === "string") {
3560
+ channelID = channelIDOrCustom;
3561
+ } else if (typeof channelIDOrCustom === "object" && channelIDOrCustom !== null) {
3562
+ customData = channelIDOrCustom;
3563
+ }
3564
+ return this.getChannelById(channelType, channelID, customData);
3558
3565
  }
3559
3566
  getChannelById = (channelType, channelID, custom) => {
3560
- const cid = `${channelType}:${channelID}`;
3567
+ const cid = `${channelType}:${channelID || ""}`;
3561
3568
  if (cid in this.activeChannels && !this.activeChannels[cid].disconnected) {
3562
3569
  const channel2 = this.activeChannels[cid];
3563
3570
  if (Object.keys(custom).length > 0) {
@@ -3600,7 +3607,7 @@ var ErmisChat = class _ErmisChat {
3600
3607
  return pinExpires;
3601
3608
  }
3602
3609
  getUserAgent() {
3603
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.0"}`;
3610
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.2"}`;
3604
3611
  }
3605
3612
  setUserAgent(userAgent) {
3606
3613
  this.userAgent = userAgent;
@@ -6933,7 +6940,7 @@ var ErmisAuthProvider = class {
6933
6940
  return data;
6934
6941
  }
6935
6942
  getUserAgent() {
6936
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.0"}`;
6943
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.2"}`;
6937
6944
  }
6938
6945
  setUserAgent(userAgent) {
6939
6946
  this.userAgent = userAgent;