@ermis-network/ermis-chat-sdk 1.0.1 → 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.
package/dist/index.cjs CHANGED
@@ -3604,17 +3604,24 @@ var ErmisChat = class _ErmisChat {
3604
3604
  async unpinChannel(channelType, channelId) {
3605
3605
  return await this.post(this.baseURL + `/channels/${channelType}/${channelId}/unpin`);
3606
3606
  }
3607
- channel(channelType, channelID, custom = {}) {
3607
+ channel(channelType, channelIDOrCustom, custom) {
3608
3608
  if (!this.userID) {
3609
3609
  throw Error("Call connectUser before creating a channel");
3610
3610
  }
3611
3611
  if (~channelType.indexOf(":")) {
3612
3612
  throw Error(`Invalid channel group ${channelType}, can't contain the : character`);
3613
3613
  }
3614
- return this.getChannelById(channelType, channelID, custom);
3614
+ let channelID = void 0;
3615
+ let customData = custom || {};
3616
+ if (typeof channelIDOrCustom === "string") {
3617
+ channelID = channelIDOrCustom;
3618
+ } else if (typeof channelIDOrCustom === "object" && channelIDOrCustom !== null) {
3619
+ customData = channelIDOrCustom;
3620
+ }
3621
+ return this.getChannelById(channelType, channelID, customData);
3615
3622
  }
3616
3623
  getChannelById = (channelType, channelID, custom) => {
3617
- const cid = `${channelType}:${channelID}`;
3624
+ const cid = `${channelType}:${channelID || ""}`;
3618
3625
  if (cid in this.activeChannels && !this.activeChannels[cid].disconnected) {
3619
3626
  const channel2 = this.activeChannels[cid];
3620
3627
  if (Object.keys(custom).length > 0) {
@@ -3657,7 +3664,7 @@ var ErmisChat = class _ErmisChat {
3657
3664
  return pinExpires;
3658
3665
  }
3659
3666
  getUserAgent() {
3660
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.1"}`;
3667
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.2"}`;
3661
3668
  }
3662
3669
  setUserAgent(userAgent) {
3663
3670
  this.userAgent = userAgent;
@@ -6992,7 +6999,7 @@ var ErmisAuthProvider = class {
6992
6999
  return data;
6993
7000
  }
6994
7001
  getUserAgent() {
6995
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.1"}`;
7002
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.2"}`;
6996
7003
  }
6997
7004
  setUserAgent(userAgent) {
6998
7005
  this.userAgent = userAgent;