diff --git a/CHANGELOG.md b/CHANGELOG.md index f138d93..312cd6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## v3.0.130(AUG 7, 2020) +## v3.0.131(AUG 7, 2020) + +- Fixed duplicated `appInfo` in `SendBird.d.ts`. + +## v3.0.130(AUG 7, 2020) (DEPRECATED) - Added `order` in `GroupChannelMemberListQuery`. The value could be `member_nickname_alphabetical` (default) or `operator_then_member_alphabetical`. - Added `isMuted` in `Member`. diff --git a/README.md b/README.md index d9a6519..b068925 100644 --- a/README.md +++ b/README.md @@ -52,14 +52,11 @@ Check out [Basic Sample with SyncManager](https://github.com/sendbird/SendBird-J # [Documentation](https://docs.sendbird.com/javascript) -## v3.0.130(AUG 7, 2020) +## v3.0.131(AUG 7, 2020) If you want to check the record of other version, go to [Change Log](https://github.com/sendbird/SendBird-SDK-JavaScript/blob/master/CHANGELOG.md). -- Added `order` in `GroupChannelMemberListQuery`. The value could be `member_nickname_alphabetical` (default) or `operator_then_member_alphabetical`. -- Added `isMuted` in `Member`. -- Removed value type check in `channel.createMetaData()` and `channel.updateMetaData()`. -- Bug-fix on `profileUrl` setter. +- Fixed duplicated `appInfo` in `SendBird.d.ts`. ## [Change Log](https://github.com/sendbird/SendBird-SDK-JavaScript/blob/master/CHANGELOG.md) diff --git a/SendBird.d.ts b/SendBird.d.ts index 80ddab9..ae6fad3 100644 --- a/SendBird.d.ts +++ b/SendBird.d.ts @@ -1,5 +1,5 @@ /** - * Type Definitions for SendBird SDK v3.0.130 + * Type Definitions for SendBird SDK v3.0.131 * homepage: https://sendbird.com/ * git: https://github.com/sendbird/SendBird-SDK-JavaScript */ @@ -59,9 +59,6 @@ declare namespace SendBird { friendName?: string; } interface SendBirdInstance { - currentUser: User; - appInfo: AppInfo; - User: UserStatic; Member: MemberStatic; OpenChannel: OpenChannelStatic; @@ -84,6 +81,7 @@ declare namespace SendBird { MessageMetaArray: MessageMetaArray; Options: Options; + currentUser: User; appInfo: AppInfo; ekey: string; diff --git a/SendBird.min.js b/SendBird.min.js index fc2e14a..cbfc7c2 100644 --- a/SendBird.min.js +++ b/SendBird.min.js @@ -1,6 +1,6 @@ /** * Copyright (c) 2016 SendBird DBA (Smile Family, Inc.) - * SendBird JavaScript SDK v3.0.130 + * SendBird JavaScript SDK v3.0.131 */ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("axios"),require("form-data"),require("ws")):"function"==typeof define&&define.amd?define(["axios","form-data","ws"],n):(e=e||self).SendBird=n(e.axios,e.FormData,e.WebSocket)}(this,function(p,f,r){"use strict";function pe(e){return(pe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function i(e,n){for(var t=0;te.length)&&(n=e.length);for(var t=0,r=new Array(n);tthis.reconnectParams.retryCount){for(var c in this.disconnect({clearSession:!1,err:new _e("Websocket connection failed.",_e.WEBSOCKET_CONNECTION_FAILED)},null),this.reconnectCount=0,this.sb.connectionHandlers){this.sb.connectionHandlers[c].onReconnectFailed()}return this.sb.connecting=!1,this.sb.reconnecting=!1,this.sb.isReconnectingOnError=!1,void this.sb.ConnectionManager.errorAllReadyHandler()}this.sb.onReconnectTimerCancel=function(){i.reconnectCount=0},this.sb.reconnectTimer=setTimeout(function(){i.sb.reconnectTimer=null,i.sb.onReconnectTimerCancel=null,i.ws&&i.ws.disconnect(!0);var e=new L.ConnectionHandler;i.ws=new L(i.sb,e),i.sb.loginHandler=function(){for(var e in i.reconnectCount=0,i.sb.connecting=!1,i.sb.reconnecting=!1,i.sb.isReconnectingOnError=!1,i.sb.connectionHandlers){i.sb.connectionHandlers[e].onReconnectSucceeded()}if(i.sb.ConnectionManager.processAllReadyHandler(null),i.sb.isReconnectingOnError)for(var n in i.sb.ConnectionManager.networkHandlers)i.sb.ConnectionManager.networkHandlers[n].onReconnected();Object.keys(l.enteredChannels).forEach(function(r){l.enteredChannels[r].enter(function(e,n){if(e){var t=i.cls.FileMessageQueue;delete l.enteredChannels[r],t.delete(r)}})})},e.onOpen=function(){ye.debug("reconnect onOpen"),i.sb.loginTimer=setTimeout(function(){ye.debug("reconnect loginTimer timeout"),i.sb.loginTimer=null,i.reconnect(t,!0)},fe.COMMAND_ACK_TIMEOUT),i.sb.onLoginTimerCancel=null,i.sb.reconnecting=!1},e.onMessage=function(e){o.onRawCommandReceived(e)},e.onError=function(e){ye.debug("reconnect onError",e),i.sb.isReconnectingOnError=!0,i.sb.ConnectionManager.errorAllReadyHandler(),i.reconnect(t,!0)},e.onClose=function(){ye.debug("reconnect onClose"),i.sb.reconnecting=!1},s.checkRouting(function(e,n){e?i.reconnect(t,!0):(i.sb.getCurrentApiHost()!==n.apiHost&&s.get("/",null,function(){}),i.ws.connect(t,null,n.wsHost))})},this.reconnectDelay)}}},{key:"disconnect",value:function(e,n){var t=ge.get(this.sb._iid),r=t.container.ackStateMap,i=this.cls,a=i.GroupChannel,s=i.OpenChannel,o=e.clearSession,l=e.err;if(this.sb.loginTimer&&(clearTimeout(this.sb.loginTimer),this.sb.onLoginTimerCancel&&(this.sb.onLoginTimerCancel(),this.sb.onLoginTimerCancel=null),this.sb.loginTimer=null),this.sb.reconnectTimer&&(clearTimeout(this.sb.reconnectTimer),this.sb.onReconnectTimerCancel&&(this.sb.onReconnectTimerCancel(),this.sb.onReconnectTimerCancel=null),this.sb.reconnectTimer=null),this.ws&&(this.reconnectCount=0,this.ws.disconnect(!0),this.ws=null),o){for(var u in s.clearEnteredChannels(),s.clearCache(),a.clearCache(),this.sb.globalTimer&&(clearInterval(this.sb.globalTimer),this.sb.globalTimer=null),r)clearTimeout(r[u].timer);this.sb.currentUser=null,t.set("ackStateMap",{}),t.set("subscribedUnreadMessageCount",{all:0,custom_types:{},ts:0}),t.set("auth",new A)}l&&(this.flushConnectionCallbacks(l,null),this.sb.connecting=!1,this.sb.reconnecting=!1,this.sb.isReconnectingOnError=!1),n&&n(null,null)}},{key:"flushConnectionCallbacks",value:function(n,t){var e=this.sb.connectionCallbacks;this.sb.connectionCallbacks=[],e.forEach(function(e){return e(n,t)})}}]),n}(),w=function(){function f(e){var n=e.type,t=e.nullable,r=void 0!==t&&t,i=e.optional,a=void 0!==i&&i,s=e.optionalIf,o=void 0===s?null:s,l=e.ignoreIf,u=void 0===l?null:l,c=e.defaultValue,d=void 0===c?null:c,h=e.constraint,p=void 0===h?null:h;v(this,f),this.type=n,this.nullable=r,this.optional=a,this.optionalIf=o,this.ignoreIf=u,this.defaultValue=d,this.constraint=p}return s(f,[{key:"isMatchingType",value:function(t){function n(e,n){return"string"==typeof n?pe(e)===n||"array"===n&&Array.isArray(e)||"file"===n&&me.isFile(e)||"null"===n&&null===e||"date"===n&&e instanceof Date:"function"==typeof n?e instanceof n:"object"===pe(n)&&-1m.ts){if(m.all!==b.unread_cnt.all&&(A=!0),m.all=0<=b.unread_cnt.all?b.unread_cnt.all:0,b.unread_cnt.custom_types)for(var N in b.unread_cnt.custom_types)m.custom_types[N]!==b.unread_cnt.custom_types[N]&&(A=!0),m.custom_types[N]=b.unread_cnt.custom_types[N];A=A&&0=F.createAt,a=v.sb.currentUser;a&&j&&(a.nickname!==F._sender.nickname&&(a.nickname=F._sender.nickname),a.plainProfileUrl!==F._sender.plainProfileUrl&&(a.plainProfileUrl=F._sender.plainProfileUrl),me.deepEqual(a.metaData,F._sender.metaData)||(a.metaData=F._sender.metaData));var s=!1,o=!1;if(!j&&!i&&b&&b.hasOwnProperty("old_values")){var l=b.old_values.mention_type||F.mentionType,u=b.old_values.mentioned_user_ids||F.mentionedUsers.map(function(e){return e.userId});if(l===C.MentionType.USERS&&F.mentionType===C.MentionType.USERS){for(var c=!1,d=!1,h=0;h=be.get(this)&&(be.set(this,t),this.memberCount=e,this.joinedMemberCount=n)}},{key:"hide",value:function(i,a,e){var n,s=this,t=C(w.parse(arguments,[new w({type:"boolean",optional:!0,defaultValue:!1}),new w({type:"boolean",optional:!0,defaultValue:!0}),new w({type:"callback"})]),4);return n=t[0],i=t[1],a=t[2],e=t[3],Y(this._iid,function(r){n?r(n,null):ge.get(s._iid).container.apiClient.hideGroupChannel({channelUrl:s.url,hidePreviousMessages:i,allowAutoUnhide:a},function(e,n){if(!e){var t=de.get(s._iid).GroupChannel;s.isHidden=!0,s.hiddenState=a?t.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:t.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,i&&s._setGroupChannelUnreadCount(0,0),n.hasOwnProperty("ts_message_offset")&&(s._messageOffsetTimestamp=n.ts_message_offset),t.cachedChannels[s.url]=s}r(e,n)})},e)}},{key:"unhide",value:function(e){var i=this;return Y(this._iid,function(r){ge.get(i._iid).container.apiClient.unhideGroupChannel({channelUrl:i.url},function(e,n){if(!e){var t=de.get(i._iid).GroupChannel;i.isHidden=!1,i.hiddenState=t.HiddenState.UNHIDDEN,t.cachedChannels[i.url]=i}r(e,n)})},e)}},{key:"freeze",value:function(e){var r=this;return Y(this._iid,function(t){ge.get(r._iid).container.apiClient.freeze({channelUrl:r.url,isGroupChannel:!0,freezing:!0},function(e,n){e||de.get(r._iid).GroupChannel.upsert(n);t(e,null)})},e)}},{key:"unfreeze",value:function(e){var r=this;return Y(this._iid,function(t){ge.get(r._iid).container.apiClient.freeze({channelUrl:r.url,isGroupChannel:!0,freezing:!1},function(e,n){e||de.get(r._iid).GroupChannel.upsert(n);t(e,null)})},e)}},{key:"delete",value:function(e){var r=this;return Y(this._iid,function(t){ge.get(r._iid).container.apiClient.deleteGroupChannel({channelUrl:r.url},function(e,n){e||de.get(r._iid).GroupChannel.removeCachedChannel(r.url);t(e,n)})},e)}},{key:"markAsRead",value:function(){var i=this,e=de.get(this._iid).Command,a=Nn.getInstance(this._iid),n=e.bRead({channelUrl:this.url});a.sendCommand(n,function(e,n){if(a.getErrorFirstCallback()){var t=[e,n];n=t[0],e=t[1]}if(!n&&a.currentUser&&(i.updateReadReceipt(a.currentUser.userId,e.getJsonElement().ts),0=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){t=e[Symbol.iterator]()},n:function(){var e=t.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==t.return||t.return()}finally{if(o)throw a}}}}(this.members);try{for(a.s();!(t=a.n()).done;){var s=t.value;n.currentUser.userId===s.userId||e.sender&&e.sender.userId===s.userId||this.cachedDeliveryReceiptStatus[s.userId]=e.createdAt&&i.push(s)}return i}return[]}},{key:"getUnreadMembers",value:function(e,n){var t=1=t){r.end=0,r.start=n;var i=de.get(this._iid).Command.bTypeStart({channelUrl:this.url,time:r.start});e.sendCommand(i,null)}}},{key:"endTyping",value:function(){var e=Nn.getInstance(this._iid),n=(new Date).getTime(),t=e.Options.typingIndicatorThrottle;("number"!=typeof t||t<1e3||9e3=t){r.start=0,r.end=n;var i=de.get(this._iid).Command.bTypeEnd({channelUrl:this.url,time:r.end});e.sendCommand(i,null)}}},{key:"invalidateTypingStatus",value:function(){var e=he.get(this),n=(new Date).getTime(),t=!1;for(var r in e){1e4<=n-e[r]&&(delete e[r],t=!0)}return t}},{key:"getTypingMembers",value:function(){var e=he.get(this),n=[];for(var t in e){var r=this.memberMap[t];r&&n.push(r)}return n}},{key:"updateTypingStatus",value:function(e,n){var t=he.get(this);n?t[e.userId]=(new Date).getTime():delete t[e.userId]}},{key:"isTyping",value:function(){var e=he.get(this);return 0!==Object.keys(e).length}},{key:"registerScheduledUserMessage",value:function(e,n){var t,a=this,r=de.get(this._iid),s=r.ScheduledUserMessage,i=r.ScheduledUserMessageParams,o=C(w.parse(arguments,[new w({type:i,constraint:function(e){return"string"==typeof e.message&&"string"==typeof e._getScheduleString()}}),new w({type:"callback"})]),3);return t=o[0],e=o[1],n=o[2],Y(this._iid,function(i){t?i(t,null):ge.get(a._iid).container.apiClient.registerScheduledUserMessage({groupChannelParams:e,channelUrl:a.url,isOpenChannel:!1},function(e,n){var t=null;if(!e){t=new s(n);var r=Nn.getInstance(a._iid).currentUser;r&&t._sender&&r.userId===t._sender.userId&&(r.nickname=t._sender.nickname,r.plainProfileUrl=t._sender.plainProfileUrl,r.metaData=t._sender.metaData)}i(e,t)})},n)}},{key:"getPushPreference",value:function(e){var i=this;return Y(this._iid,function(r){ge.get(i._iid).container.apiClient.getMyPushTriggerOption({channelUrl:i.url},function(e,n){var t=null;if(!e){try{t=n.enable}catch(e){t=!1}i.isPushEnabled=t}r&&r(e,t)})},e)}},{key:"setPushPreference",value:function(e,n){var i=this;return Y(this._iid,function(t){var r=de.get(i._iid).GroupChannel;ge.get(i._iid).container.apiClient.setMyPushTriggerOption({channelUrl:i.url,enable:e},function(e,n){e||(i.isPushEnabled=n.enable,i.isPushEnabled||(i.myPushTriggerOption=r.PushTriggerOption.OFF)),t(e,n)})},n)}},{key:"getMyPushTriggerOption",value:function(e){var i=this;return Y(this._iid,function(r){ge.get(i._iid).container.apiClient.getMyPushTriggerOption({channelUrl:i.url},function(e,n){var t=null;if(!e){try{t=n.push_trigger_option||a.PushTriggerOption.DEFAULT}catch(e){ye.debug(e)}i.myPushTriggerOption=t}r(e,t)})},e)}},{key:"setMyPushTriggerOption",value:function(e,n){var t,i=this,r=de.get(this._iid).GroupChannel,a=C(w.parse(arguments,[new w({type:r.PushTriggerOption}),new w({type:"callback"})]),3);return t=a[0],e=a[1],n=a[2],Y(this._iid,function(r){t?r(t,null):ge.get(i._iid).container.apiClient.setMyPushTriggerOption({channelUrl:i.url,pushTriggerOption:e},function(e,n){var t=null;if(!e){try{t=n.push_trigger_option}catch(e){ye.debug(e)}i.myPushTriggerOption=t}r(e,t)})},n)}},{key:"setMyCountPreference",value:function(e,n){var t,i=this,a=de.get(this._iid).GroupChannel,r=C(w.parse(arguments,[new w({type:a.CountPreference}),new w({type:"callback"})]),3);return t=r[0],e=r[1],n=r[2],Y(this._iid,function(r){t?r(t,null):ge.get(i._iid).container.apiClient.setMyCountPreference({channelUrl:i.url,countPreference:e},function(e,n){var t=null;e||(t=i.myCountPreference=n.count_preference,i._setGroupChannelUnreadCount(i.unreadMessageCount,i.unreadMentionCount),a.cachedChannels[i.url]=i),r(e,t)})},n)}},{key:"resetMyHistory",value:function(e){var i=this;return Y(this._iid,function(r){ge.get(i._iid).container.apiClient.resetMyHistory({channelUrl:i.url},function(e,n){if(!e&&n.hasOwnProperty("ts_message_offset")){var t=de.get(i._iid).GroupChannel;i._messageOffsetTimestamp=n.ts_message_offset,t.cachedChannels[i.url]=i}r(e,n)})},e)}},{key:"messageOffsetTimestamp",get:function(){return this._messageOffsetTimestamp}}],[{key:"buildFromSerializedData",value:function(e){var n,t=de.get(this._iid),r=t.User,i=t.Member,a=t.GroupChannel,s=t.BaseMessage,o=t.UserMessage,l=t.FileMessage,u=t.AdminMessage,c=x.deserialize(e);return new a({channel_url:c.url,name:c.name,cover_url:c.coverUrl,data:c.data,custom_type:c.customType,invited_at:c.invitedAt,created_at:c.createdAt/1e3,is_access_code_required:c.isAccessCodeRequired,is_distinct:c.isDistinct,is_super:c.isSuper,is_broadcast:c.isBroadcast,is_public:c.isPublic,is_discoverable:c.isDiscoverable,freeze:c.isFrozen,is_ephemeral:c.isEphemeral,unread_message_count:c.unreadMessageCount,unread_mention_count:c.unreadMentionCount,is_push_enabled:c.isPushEnabled,push_trigger_option:c.myPushTriggerOption,count_preference:c.myCountPreference,is_hidden:c.isHidden,hidden_state:c.hiddenState,member_count:c.memberCount,joined_member_count:c.joinedMemberCount,member_state:c.myMemberState,my_role:c.myRole,is_muted:c.myMutedState,user_last_read:c.myLastRead,ts_message_offset:c.messageOffsetTimestamp,message_survival_seconds:c.messageSurvivalSeconds,read_receipt:c.cachedReadReceiptStatus,delivery_receipt:c.cachedDeliveryReceiptStatus,members:c.members.map(function(e){return i.objectify(g({user:e},e))}),last_message:null!=(n=c.lastMessage)&&"object"===pe(n)?n.messageType===s.MESSAGE_TYPE_USER?new o(o.objectify(g(g({},n),{},{channel:{url:n.channelUrl,channelType:n.channelType},user:n.sender,mentionedUsers:n.mentionedUsers}))):n.messageType===s.MESSAGE_TYPE_FILE?new l(l.objectify(g(g({},n),{},{channel:{url:n.channelUrl,channelType:n.channelType},user:n.sender,mentionedUsers:n.mentionedUsers}))):new u(u.objectify(g(g({},n),{},{channel:{url:n.channelUrl,channelType:n.channelType},mentionedUsers:n.mentionedUsers}))):null,inviter:null!==c.inviter&&void 0!==c.inviter&&"object"===pe(c.inviter)?r.objectify(c.inviter):null})}},{key:"upsert",value:function(e){var n=de.get(this._iid).GroupChannel,t=new n(e);if(n.cachedChannels.hasOwnProperty(t.url)){if(t.isEphemeral){var r=n.cachedChannels[t.url];e.last_message=r.lastMessage,e.unread_message_count=r.unreadMessageCount}n.cachedChannels[t.url].update(e)}else n.cachedChannels[t.url]=t;return n.cachedChannels[t.url]}},{key:"removeCachedChannel",value:function(e){var n=de.get(this._iid),t=n.GroupChannel,r=n.FileMessageQueue;t.cachedChannels[e]&&delete t.cachedChannels[e],r.delete(e)}},{key:"clearCache",value:function(){ue[this._iid]={},de.get(this._iid).FileMessageQueue.clear()}},{key:"getChannel",value:function(n,e){var t,r,i=C(w.parse(arguments,[new w({type:"string"}),new w({type:"string",optional:!0,nullable:!0,defaultValue:null}),new w({type:"callback"})]),4);if(t=i[0],n=i[1],r=i[2],e=i[3],t)return Y(this._iid,function(e){e(t,null)},e);var a=de.get(this._iid).GroupChannel;return a.cachedChannels[n]?Y(this._iid,function(e){e(null,a.cachedChannels[n])},e):a.getChannelWithoutCache(n,r,e)}},{key:"getChannelWithoutCache",value:function(e,n){var t,i,a=this,r=C(w.parse(arguments,[new w({type:"string"}),new w({type:"string",optional:!0,nullable:!0,defaultValue:null}),new w({type:"callback"})]),4);return t=r[0],e=r[1],i=r[2],n=r[3],Y(this._iid,function(r){t?r(t,null):ge.get(a._iid).container.apiClient.getGroupChannel({channelUrl:e,internalCall:i,showMember:!0},function(e,n){var t=null;e||(t=a.upsert(n)),r(e,t)})},n)}},{key:"createDistinctChannelIfNotExist",value:function(e,n){var t,a=this,r=de.get(this._iid).GroupChannelParams,i=C(w.parse(arguments,[new w({type:r,constraint:function(e){return e._validate()}}),new w({type:"callback"})]),3);return t=i[0],e=i[1],n=i[2],Y(this._iid,function(i){t?i(t,null):(e.isPublic||(e.accessCode=null),ge.get(a._iid).container.apiClient.createGroupChannel(g(g({},e),{},{isDistinct:!0}),function(e,n){var t=null;if(!e){var r=de.get(a._iid).GroupChannel;t={channel:new r(n),isCreated:n.is_created},r.cachedChannels[t.channel.url]=t.channel}i(e,t)}))},n)}},{key:"createChannel",value:function(){var n=this,t=w.toArray(arguments),e=void 0;"function"==typeof t[t.length-1]&&(e=t.pop());var r=de.get(this._iid),i=r.GroupChannel,a=r.GroupChannelParams;if(t[0]instanceof a&&1===t.length)return Y(this._iid,function(r){var e=t[0];(e.isPublic||(e.accessCode=null),e._validate())?ge.get(n._iid).container.apiClient.createGroupChannel(e,function(e,n){var t=null;e||(t=new i(n),i.cachedChannels[t.url]=t),r(e,t)}):r(w.error,null)},e);if(Array.isArray(t[0])){var s=new a;switch(t.length){case 1:s.addUsers(t[0]);break;case 2:s.addUsers(t[0]),s.isDistinct=t[1];break;case 3:s.addUsers(t[0]),s.isDistinct=t[1],s.customType=t[2];break;case 5:s.addUsers(t[0]),s.isDistinct=t[1],s.name=t[2],"string"==typeof t[3]?s.coverUrl=t[3]:s.coverImage=t[3],s.data=t[4];break;case 6:s.addUsers(t[0]),s.isDistinct=t[1],s.name=t[2],"string"==typeof t[3]?s.coverUrl=t[3]:s.coverImage=t[3],s.data=t[4],s.customType=t[5];break;default:return Y(this._iid,function(e){return e(w.error,null)},e)}return e?i.createChannel(s,e):i.createChannel(s)}return Y(this._iid,function(e){return e(w.error,null)},e)}},{key:"createChannelWithUserIds",value:function(){var e=w.toArray(arguments),n=void 0;"function"==typeof e[e.length-1]&&(n=e.pop());var t=de.get(this._iid),r=t.GroupChannel,i=new t.GroupChannelParams;switch(e.length){case 1:i.addUserIds(e[0]);break;case 2:i.addUserIds(e[0]),i.isDistinct=e[1];break;case 3:i.addUserIds(e[0]),i.isDistinct=e[1],i.customType=e[2];break;case 5:i.addUserIds(e[0]),i.isDistinct=e[1],i.name=e[2],"string"==typeof e[3]?i.coverUrl=e[3]:i.coverImage=e[3],i.data=e[4];break;case 6:i.addUserIds(e[0]),i.isDistinct=e[1],i.name=e[2],"string"==typeof e[3]?i.coverUrl=e[3]:i.coverImage=e[3],i.data=e[4],i.customType=e[5];break;default:return Y(this._iid,function(e){return e(w.error,null)},n)}return r.createChannel(i,n)}},{key:"createMyGroupChannelListQuery",value:function(){return new(de.get(this._iid).GroupChannelListQuery)}},{key:"createPublicGroupChannelListQuery",value:function(){return new(de.get(this._iid).PublicGroupChannelListQuery)}},{key:"getChannelCount",value:function(e,n){return Nn.getInstance(this._iid).getGroupChannelCount(e,n)}},{key:"getUnreadItemCount",value:function(e,n){return Nn.getInstance(this._iid).getUnreadItemCount(e,n)}},{key:"getTotalUnreadMessageCount",value:function(){var e=w.toArray(arguments),n="function"==typeof e[e.length-1]?e.pop():null,t=Nn.getInstance(this._iid);return t.getTotalUnreadMessageCount.apply(t,b(e).concat([n]))}},{key:"getTotalUnreadChannelCount",value:function(e){return Nn.getInstance(this._iid).getTotalUnreadChannelCount(e)}},{key:"MemberStateFilter",get:function(){return{ALL:"all",JOINED:"joined_only",INVITED:"invited_only",INVITED_BY_FRIEND:"invited_by_friend",INVITED_BY_NON_FRIEND:"invited_by_non_friend"}}},{key:"PushTriggerOption",get:function(){return{DEFAULT:"default",ALL:"all",MENTION_ONLY:"mention_only",OFF:"off"}}},{key:"CountPreference",get:function(){return{ALL:"all",UNREAD_MESSAGE_COUNT_ONLY:"unread_message_count_only",UNREAD_MENTION_COUNT_ONLY:"unread_mention_count_only",OFF:"off"}}},{key:"HiddenState",get:function(){return{UNHIDDEN:"unhidden",HIDDEN_ALLOW_AUTO_UNHIDE:"hidden_allow_auto_unhide",HIDDEN_PREVENT_AUTO_UNHIDE:"hidden_prevent_auto_unhide"}}},{key:"PublicChannelFilter",get:function(){return{ALL:"all",PUBLIC:"public",PRIVATE:"private"}}},{key:"SuperChannelFilter",get:function(){return{ALL:"all",SUPER:"super",NON_SUPER:"nonsuper"}}},{key:"UnreadChannelFilter",get:function(){return{ALL:"all",UNREAD_MESSAGE:"unread_message"}}},{key:"HiddenChannelFilter",get:function(){return{UNHIDDEN:"unhidden_only",HIDDEN:"hidden_only",HIDDEN_ALLOW_AUTO_UNHIDE:"hidden_allow_auto_unhide",HIDDEN_PREVENT_AUTO_UNHIDE:"hidden_prevent_auto_unhide"}}},{key:"Role",get:function(){return{OPERATOR:"operator",NONE:"none"}}},{key:"UnreadItemKey",get:function(){return{GROUP_CHANNEL_UNREAD_MENTION_COUNT:"group_channel_unread_mention_count",NONSUPER_UNREAD_MENTION_COUNT:"non_super_group_channel_unread_mention_count",SUPER_UNREAD_MENTION_COUNT:"super_group_channel_unread_mention_count",GROUP_CHANNEL_UNREAD_MESSAGE_COUNT:"group_channel_unread_message_count",NONSUPER_UNREAD_MESSAGE_COUNT:"non_super_group_channel_unread_message_count",SUPER_UNREAD_MESSAGE_COUNT:"super_group_channel_unread_message_count",GROUP_CHANNEL_INVITATION_COUNT:"group_channel_invitation_count",NONSUPER_INVITATION_COUNT:"non_super_group_channel_invitation_count",SUPER_INVITATION_COUNT:"super_group_channel_invitation_count"}}},{key:"cachedChannels",get:function(){return ue[this._iid]||(ue[this._iid]={}),ue[this._iid]}},{key:"markAsReadAllLastSentAt",get:function(){return ce[this._iid]||0},set:function(e){ce[this._iid]=e}}]),a}(),Ie=function(){o(r,J);var t=h(r);function r(e){var n;return v(this,r),(n=t.call(this,e)).state="",n.role="",n.isMuted=!1,n.isBlockedByMe=!1,n.isBlockingMe=!1,e&&n._update(e),n}return s(r,[{key:"_update",value:function(e){this.state=e.state,this.role=e.role||Ae.Role.NONE,e.hasOwnProperty("is_muted")&&(this.isMuted=e.is_muted),e.hasOwnProperty("is_blocked_by_me")&&(this.isBlockedByMe=e.is_blocked_by_me),e.hasOwnProperty("is_blocking_me")&&(this.isBlockingMe=e.is_blocking_me)}},{key:"parse",value:function(e){this._update(e)}}],[{key:"objectify",value:function(e){var n=de.get(this._iid).User,t=e.user,r=e.state,i=e.role,a=void 0===i?"":i,s=e.isMuted,o=void 0!==s&&s,l=e.isBlockedByMe,u=void 0!==l&&l,c=e.isBlockingMe,d=void 0!==c&&c,h=n.objectify(t);return h.state=r,h.role=a,h.is_muted=o,h.is_blocked_by_me=u,h.is_blocking_me=d,h}},{key:"build",value:function(e,n,t,r,i,a){var s=de.get(this._iid).User;return this.objectify({user:new s(e),state:n,role:t,isMuted:r,isBlockedByMe:i,isBlockingMe:a})}},{key:"buildFromSerializedData",value:function(e){var n=de.get(this._iid).Member,t=x.deserialize(e);return new n(n.objectify(g({user:t},t)))}},{key:"JOINED",get:function(){return"joined"}},{key:"INVITED",get:function(){return"invited"}}]),r}(),Ne=function(){o(r,J);var t=h(r);function r(e){var n;return v(this,r),(n=t.call(this,e)).isBlockedByMe=!1,e&&n._update(e),n}return s(r,[{key:"parse",value:function(e){this._update(e)}},{key:"_update",value:function(e){e.hasOwnProperty("is_blocked_by_me")&&(this.isBlockedByMe=e.is_blocked_by_me)}}],[{key:"objectify",value:function(e){var n=de.get(this._iid).User,t=e.user,r=e.isBlockedByMe,i=void 0!==r&&r,a=n.objectify(t);return a.is_blocked_by_me=i,a}},{key:"build",value:function(e,n){var t=de.get(this._iid).User;return this.objectify({user:new t(e),isBlockedByMe:n})}},{key:"buildFromSerializedData",value:function(e){var n=de.get(this._iid).Sender,t=x.deserialize(e);return new n(n.objectify(g({user:t},t)))}}]),r}(),Se=function(){function n(e){v(this,n),this.emojiHash=null,this.emojiCategories=null,e&&this._update(e)}return s(n,[{key:"_update",value:function(e){var n=de.get(this._iid).EmojiCategory;this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map(function(e){return new n(e)}):[]}}]),n}(),ke=function(){function n(e){v(this,n),this.id=null,this.name=null,this.url=null,this.emojis=null,e&&this._update(e)}return s(n,[{key:"_update",value:function(e){var n=de.get(this._iid).Emoji;this.id=e.id||0,this.name=e.name||"",this.url=e.url||"",this.emojis=e.emojis?e.emojis.map(function(e){return new n(e)}):[]}}]),n}(),Re=function(){function n(e){v(this,n),this.key=null,this.url=null,e&&this._update(e)}return s(n,[{key:"_update",value:function(e){this.key=e.key,this.url=e.url}}]),n}(),Me={},Te={},Oe=function(){o(r,Z);var t=h(r);function r(e){var n;return v(this,r),(n=t.call(this,e)).channelType=Z.CHANNEL_TYPE_OPEN,n.participantCount=0,n.operators=[],e&&n._update(e),n}return s(r,[{key:"_update",value:function(e){var n=de.get(this._iid).User;e.hasOwnProperty("participant_count")&&(this.participantCount=parseInt(e.participant_count)),e.hasOwnProperty("operators")&&Array.isArray(e.operators)&&(this.operators=e.operators.map(function(e){return new n(e)}))}},{key:"parse",value:function(e){this._update(e)}},{key:"update",value:function(e){this.__update(e),this._update(e)}},{key:"createParticipantListQuery",value:function(){return new(de.get(this._iid).ParticipantListQuery)({channelUrl:this.url})}},{key:"createMutedUserListQuery",value:function(){return new(de.get(this._iid).MutedUserListQuery)({channelUrl:this.url,isOpenChannel:!0})}},{key:"createBannedUserListQuery",value:function(){return new(de.get(this._iid).BannedUserListQuery)({channelUrl:this.url,isOpenChannel:!0})}},{key:"isOperator",value:function(e){return!!e&&this.isOperatorWithUserId(e.userId)}},{key:"isOperatorWithUserId",value:function(e){return-1e.length)&&(n=e.length);for(var t=0,r=new Array(n);tthis.reconnectParams.retryCount){for(var c in this.disconnect({clearSession:!1,err:new _e("Websocket connection failed.",_e.WEBSOCKET_CONNECTION_FAILED)},null),this.reconnectCount=0,this.sb.connectionHandlers){this.sb.connectionHandlers[c].onReconnectFailed()}return this.sb.connecting=!1,this.sb.reconnecting=!1,this.sb.isReconnectingOnError=!1,void this.sb.ConnectionManager.errorAllReadyHandler()}this.sb.onReconnectTimerCancel=function(){i.reconnectCount=0},this.sb.reconnectTimer=setTimeout(function(){i.sb.reconnectTimer=null,i.sb.onReconnectTimerCancel=null,i.ws&&i.ws.disconnect(!0);var e=new L.ConnectionHandler;i.ws=new L(i.sb,e),i.sb.loginHandler=function(){for(var e in i.reconnectCount=0,i.sb.connecting=!1,i.sb.reconnecting=!1,i.sb.isReconnectingOnError=!1,i.sb.connectionHandlers){i.sb.connectionHandlers[e].onReconnectSucceeded()}if(i.sb.ConnectionManager.processAllReadyHandler(null),i.sb.isReconnectingOnError)for(var n in i.sb.ConnectionManager.networkHandlers)i.sb.ConnectionManager.networkHandlers[n].onReconnected();Object.keys(l.enteredChannels).forEach(function(r){l.enteredChannels[r].enter(function(e,n){if(e){var t=i.cls.FileMessageQueue;delete l.enteredChannels[r],t.delete(r)}})})},e.onOpen=function(){ye.debug("reconnect onOpen"),i.sb.loginTimer=setTimeout(function(){ye.debug("reconnect loginTimer timeout"),i.sb.loginTimer=null,i.reconnect(t,!0)},fe.COMMAND_ACK_TIMEOUT),i.sb.onLoginTimerCancel=null,i.sb.reconnecting=!1},e.onMessage=function(e){o.onRawCommandReceived(e)},e.onError=function(e){ye.debug("reconnect onError",e),i.sb.isReconnectingOnError=!0,i.sb.ConnectionManager.errorAllReadyHandler(),i.reconnect(t,!0)},e.onClose=function(){ye.debug("reconnect onClose"),i.sb.reconnecting=!1},s.checkRouting(function(e,n){e?i.reconnect(t,!0):(i.sb.getCurrentApiHost()!==n.apiHost&&s.get("/",null,function(){}),i.ws.connect(t,null,n.wsHost))})},this.reconnectDelay)}}},{key:"disconnect",value:function(e,n){var t=ge.get(this.sb._iid),r=t.container.ackStateMap,i=this.cls,a=i.GroupChannel,s=i.OpenChannel,o=e.clearSession,l=e.err;if(this.sb.loginTimer&&(clearTimeout(this.sb.loginTimer),this.sb.onLoginTimerCancel&&(this.sb.onLoginTimerCancel(),this.sb.onLoginTimerCancel=null),this.sb.loginTimer=null),this.sb.reconnectTimer&&(clearTimeout(this.sb.reconnectTimer),this.sb.onReconnectTimerCancel&&(this.sb.onReconnectTimerCancel(),this.sb.onReconnectTimerCancel=null),this.sb.reconnectTimer=null),this.ws&&(this.reconnectCount=0,this.ws.disconnect(!0),this.ws=null),o){for(var u in s.clearEnteredChannels(),s.clearCache(),a.clearCache(),this.sb.globalTimer&&(clearInterval(this.sb.globalTimer),this.sb.globalTimer=null),r)clearTimeout(r[u].timer);this.sb.currentUser=null,t.set("ackStateMap",{}),t.set("subscribedUnreadMessageCount",{all:0,custom_types:{},ts:0}),t.set("auth",new A)}l&&(this.flushConnectionCallbacks(l,null),this.sb.connecting=!1,this.sb.reconnecting=!1,this.sb.isReconnectingOnError=!1),n&&n(null,null)}},{key:"flushConnectionCallbacks",value:function(n,t){var e=this.sb.connectionCallbacks;this.sb.connectionCallbacks=[],e.forEach(function(e){return e(n,t)})}}]),n}(),w=function(){function f(e){var n=e.type,t=e.nullable,r=void 0!==t&&t,i=e.optional,a=void 0!==i&&i,s=e.optionalIf,o=void 0===s?null:s,l=e.ignoreIf,u=void 0===l?null:l,c=e.defaultValue,d=void 0===c?null:c,h=e.constraint,p=void 0===h?null:h;v(this,f),this.type=n,this.nullable=r,this.optional=a,this.optionalIf=o,this.ignoreIf=u,this.defaultValue=d,this.constraint=p}return s(f,[{key:"isMatchingType",value:function(t){function n(e,n){return"string"==typeof n?pe(e)===n||"array"===n&&Array.isArray(e)||"file"===n&&me.isFile(e)||"null"===n&&null===e||"date"===n&&e instanceof Date:"function"==typeof n?e instanceof n:"object"===pe(n)&&-1m.ts){if(m.all!==b.unread_cnt.all&&(A=!0),m.all=0<=b.unread_cnt.all?b.unread_cnt.all:0,b.unread_cnt.custom_types)for(var N in b.unread_cnt.custom_types)m.custom_types[N]!==b.unread_cnt.custom_types[N]&&(A=!0),m.custom_types[N]=b.unread_cnt.custom_types[N];A=A&&0=F.createAt,a=v.sb.currentUser;a&&j&&(a.nickname!==F._sender.nickname&&(a.nickname=F._sender.nickname),a.plainProfileUrl!==F._sender.plainProfileUrl&&(a.plainProfileUrl=F._sender.plainProfileUrl),me.deepEqual(a.metaData,F._sender.metaData)||(a.metaData=F._sender.metaData));var s=!1,o=!1;if(!j&&!i&&b&&b.hasOwnProperty("old_values")){var l=b.old_values.mention_type||F.mentionType,u=b.old_values.mentioned_user_ids||F.mentionedUsers.map(function(e){return e.userId});if(l===C.MentionType.USERS&&F.mentionType===C.MentionType.USERS){for(var c=!1,d=!1,h=0;h=be.get(this)&&(be.set(this,t),this.memberCount=e,this.joinedMemberCount=n)}},{key:"hide",value:function(i,a,e){var n,s=this,t=C(w.parse(arguments,[new w({type:"boolean",optional:!0,defaultValue:!1}),new w({type:"boolean",optional:!0,defaultValue:!0}),new w({type:"callback"})]),4);return n=t[0],i=t[1],a=t[2],e=t[3],Y(this._iid,function(r){n?r(n,null):ge.get(s._iid).container.apiClient.hideGroupChannel({channelUrl:s.url,hidePreviousMessages:i,allowAutoUnhide:a},function(e,n){if(!e){var t=de.get(s._iid).GroupChannel;s.isHidden=!0,s.hiddenState=a?t.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:t.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,i&&s._setGroupChannelUnreadCount(0,0),n.hasOwnProperty("ts_message_offset")&&(s._messageOffsetTimestamp=n.ts_message_offset),t.cachedChannels[s.url]=s}r(e,n)})},e)}},{key:"unhide",value:function(e){var i=this;return Y(this._iid,function(r){ge.get(i._iid).container.apiClient.unhideGroupChannel({channelUrl:i.url},function(e,n){if(!e){var t=de.get(i._iid).GroupChannel;i.isHidden=!1,i.hiddenState=t.HiddenState.UNHIDDEN,t.cachedChannels[i.url]=i}r(e,n)})},e)}},{key:"freeze",value:function(e){var r=this;return Y(this._iid,function(t){ge.get(r._iid).container.apiClient.freeze({channelUrl:r.url,isGroupChannel:!0,freezing:!0},function(e,n){e||de.get(r._iid).GroupChannel.upsert(n);t(e,null)})},e)}},{key:"unfreeze",value:function(e){var r=this;return Y(this._iid,function(t){ge.get(r._iid).container.apiClient.freeze({channelUrl:r.url,isGroupChannel:!0,freezing:!1},function(e,n){e||de.get(r._iid).GroupChannel.upsert(n);t(e,null)})},e)}},{key:"delete",value:function(e){var r=this;return Y(this._iid,function(t){ge.get(r._iid).container.apiClient.deleteGroupChannel({channelUrl:r.url},function(e,n){e||de.get(r._iid).GroupChannel.removeCachedChannel(r.url);t(e,n)})},e)}},{key:"markAsRead",value:function(){var i=this,e=de.get(this._iid).Command,a=Nn.getInstance(this._iid),n=e.bRead({channelUrl:this.url});a.sendCommand(n,function(e,n){if(a.getErrorFirstCallback()){var t=[e,n];n=t[0],e=t[1]}if(!n&&a.currentUser&&(i.updateReadReceipt(a.currentUser.userId,e.getJsonElement().ts),0=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){t=e[Symbol.iterator]()},n:function(){var e=t.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==t.return||t.return()}finally{if(o)throw a}}}}(this.members);try{for(a.s();!(t=a.n()).done;){var s=t.value;n.currentUser.userId===s.userId||e.sender&&e.sender.userId===s.userId||this.cachedDeliveryReceiptStatus[s.userId]=e.createdAt&&i.push(s)}return i}return[]}},{key:"getUnreadMembers",value:function(e,n){var t=1=t){r.end=0,r.start=n;var i=de.get(this._iid).Command.bTypeStart({channelUrl:this.url,time:r.start});e.sendCommand(i,null)}}},{key:"endTyping",value:function(){var e=Nn.getInstance(this._iid),n=(new Date).getTime(),t=e.Options.typingIndicatorThrottle;("number"!=typeof t||t<1e3||9e3=t){r.start=0,r.end=n;var i=de.get(this._iid).Command.bTypeEnd({channelUrl:this.url,time:r.end});e.sendCommand(i,null)}}},{key:"invalidateTypingStatus",value:function(){var e=he.get(this),n=(new Date).getTime(),t=!1;for(var r in e){1e4<=n-e[r]&&(delete e[r],t=!0)}return t}},{key:"getTypingMembers",value:function(){var e=he.get(this),n=[];for(var t in e){var r=this.memberMap[t];r&&n.push(r)}return n}},{key:"updateTypingStatus",value:function(e,n){var t=he.get(this);n?t[e.userId]=(new Date).getTime():delete t[e.userId]}},{key:"isTyping",value:function(){var e=he.get(this);return 0!==Object.keys(e).length}},{key:"registerScheduledUserMessage",value:function(e,n){var t,a=this,r=de.get(this._iid),s=r.ScheduledUserMessage,i=r.ScheduledUserMessageParams,o=C(w.parse(arguments,[new w({type:i,constraint:function(e){return"string"==typeof e.message&&"string"==typeof e._getScheduleString()}}),new w({type:"callback"})]),3);return t=o[0],e=o[1],n=o[2],Y(this._iid,function(i){t?i(t,null):ge.get(a._iid).container.apiClient.registerScheduledUserMessage({groupChannelParams:e,channelUrl:a.url,isOpenChannel:!1},function(e,n){var t=null;if(!e){t=new s(n);var r=Nn.getInstance(a._iid).currentUser;r&&t._sender&&r.userId===t._sender.userId&&(r.nickname=t._sender.nickname,r.plainProfileUrl=t._sender.plainProfileUrl,r.metaData=t._sender.metaData)}i(e,t)})},n)}},{key:"getPushPreference",value:function(e){var i=this;return Y(this._iid,function(r){ge.get(i._iid).container.apiClient.getMyPushTriggerOption({channelUrl:i.url},function(e,n){var t=null;if(!e){try{t=n.enable}catch(e){t=!1}i.isPushEnabled=t}r&&r(e,t)})},e)}},{key:"setPushPreference",value:function(e,n){var i=this;return Y(this._iid,function(t){var r=de.get(i._iid).GroupChannel;ge.get(i._iid).container.apiClient.setMyPushTriggerOption({channelUrl:i.url,enable:e},function(e,n){e||(i.isPushEnabled=n.enable,i.isPushEnabled||(i.myPushTriggerOption=r.PushTriggerOption.OFF)),t(e,n)})},n)}},{key:"getMyPushTriggerOption",value:function(e){var i=this;return Y(this._iid,function(r){ge.get(i._iid).container.apiClient.getMyPushTriggerOption({channelUrl:i.url},function(e,n){var t=null;if(!e){try{t=n.push_trigger_option||a.PushTriggerOption.DEFAULT}catch(e){ye.debug(e)}i.myPushTriggerOption=t}r(e,t)})},e)}},{key:"setMyPushTriggerOption",value:function(e,n){var t,i=this,r=de.get(this._iid).GroupChannel,a=C(w.parse(arguments,[new w({type:r.PushTriggerOption}),new w({type:"callback"})]),3);return t=a[0],e=a[1],n=a[2],Y(this._iid,function(r){t?r(t,null):ge.get(i._iid).container.apiClient.setMyPushTriggerOption({channelUrl:i.url,pushTriggerOption:e},function(e,n){var t=null;if(!e){try{t=n.push_trigger_option}catch(e){ye.debug(e)}i.myPushTriggerOption=t}r(e,t)})},n)}},{key:"setMyCountPreference",value:function(e,n){var t,i=this,a=de.get(this._iid).GroupChannel,r=C(w.parse(arguments,[new w({type:a.CountPreference}),new w({type:"callback"})]),3);return t=r[0],e=r[1],n=r[2],Y(this._iid,function(r){t?r(t,null):ge.get(i._iid).container.apiClient.setMyCountPreference({channelUrl:i.url,countPreference:e},function(e,n){var t=null;e||(t=i.myCountPreference=n.count_preference,i._setGroupChannelUnreadCount(i.unreadMessageCount,i.unreadMentionCount),a.cachedChannels[i.url]=i),r(e,t)})},n)}},{key:"resetMyHistory",value:function(e){var i=this;return Y(this._iid,function(r){ge.get(i._iid).container.apiClient.resetMyHistory({channelUrl:i.url},function(e,n){if(!e&&n.hasOwnProperty("ts_message_offset")){var t=de.get(i._iid).GroupChannel;i._messageOffsetTimestamp=n.ts_message_offset,t.cachedChannels[i.url]=i}r(e,n)})},e)}},{key:"messageOffsetTimestamp",get:function(){return this._messageOffsetTimestamp}}],[{key:"buildFromSerializedData",value:function(e){var n,t=de.get(this._iid),r=t.User,i=t.Member,a=t.GroupChannel,s=t.BaseMessage,o=t.UserMessage,l=t.FileMessage,u=t.AdminMessage,c=x.deserialize(e);return new a({channel_url:c.url,name:c.name,cover_url:c.coverUrl,data:c.data,custom_type:c.customType,invited_at:c.invitedAt,created_at:c.createdAt/1e3,is_access_code_required:c.isAccessCodeRequired,is_distinct:c.isDistinct,is_super:c.isSuper,is_broadcast:c.isBroadcast,is_public:c.isPublic,is_discoverable:c.isDiscoverable,freeze:c.isFrozen,is_ephemeral:c.isEphemeral,unread_message_count:c.unreadMessageCount,unread_mention_count:c.unreadMentionCount,is_push_enabled:c.isPushEnabled,push_trigger_option:c.myPushTriggerOption,count_preference:c.myCountPreference,is_hidden:c.isHidden,hidden_state:c.hiddenState,member_count:c.memberCount,joined_member_count:c.joinedMemberCount,member_state:c.myMemberState,my_role:c.myRole,is_muted:c.myMutedState,user_last_read:c.myLastRead,ts_message_offset:c.messageOffsetTimestamp,message_survival_seconds:c.messageSurvivalSeconds,read_receipt:c.cachedReadReceiptStatus,delivery_receipt:c.cachedDeliveryReceiptStatus,members:c.members.map(function(e){return i.objectify(g({user:e},e))}),last_message:null!=(n=c.lastMessage)&&"object"===pe(n)?n.messageType===s.MESSAGE_TYPE_USER?new o(o.objectify(g(g({},n),{},{channel:{url:n.channelUrl,channelType:n.channelType},user:n.sender,mentionedUsers:n.mentionedUsers}))):n.messageType===s.MESSAGE_TYPE_FILE?new l(l.objectify(g(g({},n),{},{channel:{url:n.channelUrl,channelType:n.channelType},user:n.sender,mentionedUsers:n.mentionedUsers}))):new u(u.objectify(g(g({},n),{},{channel:{url:n.channelUrl,channelType:n.channelType},mentionedUsers:n.mentionedUsers}))):null,inviter:null!==c.inviter&&void 0!==c.inviter&&"object"===pe(c.inviter)?r.objectify(c.inviter):null})}},{key:"upsert",value:function(e){var n=de.get(this._iid).GroupChannel,t=new n(e);if(n.cachedChannels.hasOwnProperty(t.url)){if(t.isEphemeral){var r=n.cachedChannels[t.url];e.last_message=r.lastMessage,e.unread_message_count=r.unreadMessageCount}n.cachedChannels[t.url].update(e)}else n.cachedChannels[t.url]=t;return n.cachedChannels[t.url]}},{key:"removeCachedChannel",value:function(e){var n=de.get(this._iid),t=n.GroupChannel,r=n.FileMessageQueue;t.cachedChannels[e]&&delete t.cachedChannels[e],r.delete(e)}},{key:"clearCache",value:function(){ue[this._iid]={},de.get(this._iid).FileMessageQueue.clear()}},{key:"getChannel",value:function(n,e){var t,r,i=C(w.parse(arguments,[new w({type:"string"}),new w({type:"string",optional:!0,nullable:!0,defaultValue:null}),new w({type:"callback"})]),4);if(t=i[0],n=i[1],r=i[2],e=i[3],t)return Y(this._iid,function(e){e(t,null)},e);var a=de.get(this._iid).GroupChannel;return a.cachedChannels[n]?Y(this._iid,function(e){e(null,a.cachedChannels[n])},e):a.getChannelWithoutCache(n,r,e)}},{key:"getChannelWithoutCache",value:function(e,n){var t,i,a=this,r=C(w.parse(arguments,[new w({type:"string"}),new w({type:"string",optional:!0,nullable:!0,defaultValue:null}),new w({type:"callback"})]),4);return t=r[0],e=r[1],i=r[2],n=r[3],Y(this._iid,function(r){t?r(t,null):ge.get(a._iid).container.apiClient.getGroupChannel({channelUrl:e,internalCall:i,showMember:!0},function(e,n){var t=null;e||(t=a.upsert(n)),r(e,t)})},n)}},{key:"createDistinctChannelIfNotExist",value:function(e,n){var t,a=this,r=de.get(this._iid).GroupChannelParams,i=C(w.parse(arguments,[new w({type:r,constraint:function(e){return e._validate()}}),new w({type:"callback"})]),3);return t=i[0],e=i[1],n=i[2],Y(this._iid,function(i){t?i(t,null):(e.isPublic||(e.accessCode=null),ge.get(a._iid).container.apiClient.createGroupChannel(g(g({},e),{},{isDistinct:!0}),function(e,n){var t=null;if(!e){var r=de.get(a._iid).GroupChannel;t={channel:new r(n),isCreated:n.is_created},r.cachedChannels[t.channel.url]=t.channel}i(e,t)}))},n)}},{key:"createChannel",value:function(){var n=this,t=w.toArray(arguments),e=void 0;"function"==typeof t[t.length-1]&&(e=t.pop());var r=de.get(this._iid),i=r.GroupChannel,a=r.GroupChannelParams;if(t[0]instanceof a&&1===t.length)return Y(this._iid,function(r){var e=t[0];(e.isPublic||(e.accessCode=null),e._validate())?ge.get(n._iid).container.apiClient.createGroupChannel(e,function(e,n){var t=null;e||(t=new i(n),i.cachedChannels[t.url]=t),r(e,t)}):r(w.error,null)},e);if(Array.isArray(t[0])){var s=new a;switch(t.length){case 1:s.addUsers(t[0]);break;case 2:s.addUsers(t[0]),s.isDistinct=t[1];break;case 3:s.addUsers(t[0]),s.isDistinct=t[1],s.customType=t[2];break;case 5:s.addUsers(t[0]),s.isDistinct=t[1],s.name=t[2],"string"==typeof t[3]?s.coverUrl=t[3]:s.coverImage=t[3],s.data=t[4];break;case 6:s.addUsers(t[0]),s.isDistinct=t[1],s.name=t[2],"string"==typeof t[3]?s.coverUrl=t[3]:s.coverImage=t[3],s.data=t[4],s.customType=t[5];break;default:return Y(this._iid,function(e){return e(w.error,null)},e)}return e?i.createChannel(s,e):i.createChannel(s)}return Y(this._iid,function(e){return e(w.error,null)},e)}},{key:"createChannelWithUserIds",value:function(){var e=w.toArray(arguments),n=void 0;"function"==typeof e[e.length-1]&&(n=e.pop());var t=de.get(this._iid),r=t.GroupChannel,i=new t.GroupChannelParams;switch(e.length){case 1:i.addUserIds(e[0]);break;case 2:i.addUserIds(e[0]),i.isDistinct=e[1];break;case 3:i.addUserIds(e[0]),i.isDistinct=e[1],i.customType=e[2];break;case 5:i.addUserIds(e[0]),i.isDistinct=e[1],i.name=e[2],"string"==typeof e[3]?i.coverUrl=e[3]:i.coverImage=e[3],i.data=e[4];break;case 6:i.addUserIds(e[0]),i.isDistinct=e[1],i.name=e[2],"string"==typeof e[3]?i.coverUrl=e[3]:i.coverImage=e[3],i.data=e[4],i.customType=e[5];break;default:return Y(this._iid,function(e){return e(w.error,null)},n)}return r.createChannel(i,n)}},{key:"createMyGroupChannelListQuery",value:function(){return new(de.get(this._iid).GroupChannelListQuery)}},{key:"createPublicGroupChannelListQuery",value:function(){return new(de.get(this._iid).PublicGroupChannelListQuery)}},{key:"getChannelCount",value:function(e,n){return Nn.getInstance(this._iid).getGroupChannelCount(e,n)}},{key:"getUnreadItemCount",value:function(e,n){return Nn.getInstance(this._iid).getUnreadItemCount(e,n)}},{key:"getTotalUnreadMessageCount",value:function(){var e=w.toArray(arguments),n="function"==typeof e[e.length-1]?e.pop():null,t=Nn.getInstance(this._iid);return t.getTotalUnreadMessageCount.apply(t,b(e).concat([n]))}},{key:"getTotalUnreadChannelCount",value:function(e){return Nn.getInstance(this._iid).getTotalUnreadChannelCount(e)}},{key:"MemberStateFilter",get:function(){return{ALL:"all",JOINED:"joined_only",INVITED:"invited_only",INVITED_BY_FRIEND:"invited_by_friend",INVITED_BY_NON_FRIEND:"invited_by_non_friend"}}},{key:"PushTriggerOption",get:function(){return{DEFAULT:"default",ALL:"all",MENTION_ONLY:"mention_only",OFF:"off"}}},{key:"CountPreference",get:function(){return{ALL:"all",UNREAD_MESSAGE_COUNT_ONLY:"unread_message_count_only",UNREAD_MENTION_COUNT_ONLY:"unread_mention_count_only",OFF:"off"}}},{key:"HiddenState",get:function(){return{UNHIDDEN:"unhidden",HIDDEN_ALLOW_AUTO_UNHIDE:"hidden_allow_auto_unhide",HIDDEN_PREVENT_AUTO_UNHIDE:"hidden_prevent_auto_unhide"}}},{key:"PublicChannelFilter",get:function(){return{ALL:"all",PUBLIC:"public",PRIVATE:"private"}}},{key:"SuperChannelFilter",get:function(){return{ALL:"all",SUPER:"super",NON_SUPER:"nonsuper"}}},{key:"UnreadChannelFilter",get:function(){return{ALL:"all",UNREAD_MESSAGE:"unread_message"}}},{key:"HiddenChannelFilter",get:function(){return{UNHIDDEN:"unhidden_only",HIDDEN:"hidden_only",HIDDEN_ALLOW_AUTO_UNHIDE:"hidden_allow_auto_unhide",HIDDEN_PREVENT_AUTO_UNHIDE:"hidden_prevent_auto_unhide"}}},{key:"Role",get:function(){return{OPERATOR:"operator",NONE:"none"}}},{key:"UnreadItemKey",get:function(){return{GROUP_CHANNEL_UNREAD_MENTION_COUNT:"group_channel_unread_mention_count",NONSUPER_UNREAD_MENTION_COUNT:"non_super_group_channel_unread_mention_count",SUPER_UNREAD_MENTION_COUNT:"super_group_channel_unread_mention_count",GROUP_CHANNEL_UNREAD_MESSAGE_COUNT:"group_channel_unread_message_count",NONSUPER_UNREAD_MESSAGE_COUNT:"non_super_group_channel_unread_message_count",SUPER_UNREAD_MESSAGE_COUNT:"super_group_channel_unread_message_count",GROUP_CHANNEL_INVITATION_COUNT:"group_channel_invitation_count",NONSUPER_INVITATION_COUNT:"non_super_group_channel_invitation_count",SUPER_INVITATION_COUNT:"super_group_channel_invitation_count"}}},{key:"cachedChannels",get:function(){return ue[this._iid]||(ue[this._iid]={}),ue[this._iid]}},{key:"markAsReadAllLastSentAt",get:function(){return ce[this._iid]||0},set:function(e){ce[this._iid]=e}}]),a}(),Ie=function(){o(r,J);var t=h(r);function r(e){var n;return v(this,r),(n=t.call(this,e)).state="",n.role="",n.isMuted=!1,n.isBlockedByMe=!1,n.isBlockingMe=!1,e&&n._update(e),n}return s(r,[{key:"_update",value:function(e){this.state=e.state,this.role=e.role||Ae.Role.NONE,e.hasOwnProperty("is_muted")&&(this.isMuted=e.is_muted),e.hasOwnProperty("is_blocked_by_me")&&(this.isBlockedByMe=e.is_blocked_by_me),e.hasOwnProperty("is_blocking_me")&&(this.isBlockingMe=e.is_blocking_me)}},{key:"parse",value:function(e){this._update(e)}}],[{key:"objectify",value:function(e){var n=de.get(this._iid).User,t=e.user,r=e.state,i=e.role,a=void 0===i?"":i,s=e.isMuted,o=void 0!==s&&s,l=e.isBlockedByMe,u=void 0!==l&&l,c=e.isBlockingMe,d=void 0!==c&&c,h=n.objectify(t);return h.state=r,h.role=a,h.is_muted=o,h.is_blocked_by_me=u,h.is_blocking_me=d,h}},{key:"build",value:function(e,n,t,r,i,a){var s=de.get(this._iid).User;return this.objectify({user:new s(e),state:n,role:t,isMuted:r,isBlockedByMe:i,isBlockingMe:a})}},{key:"buildFromSerializedData",value:function(e){var n=de.get(this._iid).Member,t=x.deserialize(e);return new n(n.objectify(g({user:t},t)))}},{key:"JOINED",get:function(){return"joined"}},{key:"INVITED",get:function(){return"invited"}}]),r}(),Ne=function(){o(r,J);var t=h(r);function r(e){var n;return v(this,r),(n=t.call(this,e)).isBlockedByMe=!1,e&&n._update(e),n}return s(r,[{key:"parse",value:function(e){this._update(e)}},{key:"_update",value:function(e){e.hasOwnProperty("is_blocked_by_me")&&(this.isBlockedByMe=e.is_blocked_by_me)}}],[{key:"objectify",value:function(e){var n=de.get(this._iid).User,t=e.user,r=e.isBlockedByMe,i=void 0!==r&&r,a=n.objectify(t);return a.is_blocked_by_me=i,a}},{key:"build",value:function(e,n){var t=de.get(this._iid).User;return this.objectify({user:new t(e),isBlockedByMe:n})}},{key:"buildFromSerializedData",value:function(e){var n=de.get(this._iid).Sender,t=x.deserialize(e);return new n(n.objectify(g({user:t},t)))}}]),r}(),Se=function(){function n(e){v(this,n),this.emojiHash=null,this.emojiCategories=null,e&&this._update(e)}return s(n,[{key:"_update",value:function(e){var n=de.get(this._iid).EmojiCategory;this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map(function(e){return new n(e)}):[]}}]),n}(),ke=function(){function n(e){v(this,n),this.id=null,this.name=null,this.url=null,this.emojis=null,e&&this._update(e)}return s(n,[{key:"_update",value:function(e){var n=de.get(this._iid).Emoji;this.id=e.id||0,this.name=e.name||"",this.url=e.url||"",this.emojis=e.emojis?e.emojis.map(function(e){return new n(e)}):[]}}]),n}(),Re=function(){function n(e){v(this,n),this.key=null,this.url=null,e&&this._update(e)}return s(n,[{key:"_update",value:function(e){this.key=e.key,this.url=e.url}}]),n}(),Me={},Te={},Oe=function(){o(r,Z);var t=h(r);function r(e){var n;return v(this,r),(n=t.call(this,e)).channelType=Z.CHANNEL_TYPE_OPEN,n.participantCount=0,n.operators=[],e&&n._update(e),n}return s(r,[{key:"_update",value:function(e){var n=de.get(this._iid).User;e.hasOwnProperty("participant_count")&&(this.participantCount=parseInt(e.participant_count)),e.hasOwnProperty("operators")&&Array.isArray(e.operators)&&(this.operators=e.operators.map(function(e){return new n(e)}))}},{key:"parse",value:function(e){this._update(e)}},{key:"update",value:function(e){this.__update(e),this._update(e)}},{key:"createParticipantListQuery",value:function(){return new(de.get(this._iid).ParticipantListQuery)({channelUrl:this.url})}},{key:"createMutedUserListQuery",value:function(){return new(de.get(this._iid).MutedUserListQuery)({channelUrl:this.url,isOpenChannel:!0})}},{key:"createBannedUserListQuery",value:function(){return new(de.get(this._iid).BannedUserListQuery)({channelUrl:this.url,isOpenChannel:!0})}},{key:"isOperator",value:function(e){return!!e&&this.isOperatorWithUserId(e.userId)}},{key:"isOperatorWithUserId",value:function(e){return-1"], "homepage": "https://github.com/sendbird/SendBird-SDK-JavaScript", "description": "SendBird JavaScript SDK", diff --git a/package.json b/package.json index 60d5b2e..f6f1d24 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sendbird", - "version": "3.0.130", + "version": "3.0.131", "description": "SendBird JavaScript SDK", "main": "SendBird.min.js", "dependencies": {