From 0c52d8cd4cba6e79ea92a51f2bb802a45229d3ab Mon Sep 17 00:00:00 2001 From: Liam Cho Date: Wed, 31 Mar 2021 16:56:42 +0900 Subject: [PATCH] v3.0.148 --- CHANGELOG.md | 6 ++++++ README.md | 10 +++++----- SendBird.d.ts | 14 +++++++++++++- SendBird.min.js | 4 ++-- bower.json | 2 +- package.json | 2 +- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 156cc7a..f2c09c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v3.0.148(MAR 31, 2021) + +- Added `AppleCriticalAlertOptions` interface. +- Added `appleCriticalAlertOptions` in `BaseMessage`, `UserMessageParams`, `FileMessageParams`, `ScheduledUserMessage`, and `ScheduledUserMessageParams`. +- Downgraded log level from `ERROR` to `DEBUG` for all internal API calls. + ## v3.0.147(MAR 24, 2021) - Added `onChannelMemberCountChanged` and `onChannelParticipantCountChanged` in `ChannelHandler`. diff --git a/README.md b/README.md index d8a9d9a..f05ed24 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ Or download the latest Chat SDK for JavaScript from the following link if you do - https://github.com/sendbird/Sendbird-SDK-JavaScript -> **Note**: You should also add `axios` library into the @@ -325,10 +325,10 @@ The `sb.setErrorFirstCallback(false)` returns callbacks to their original parame ## Changelogs -## v3.0.147(MAR 24, 2021) +## v3.0.148(MAR 31, 2021) If you want to check the record of other versions, go to [Change Log](https://github.com/sendbird/Sendbird-SDK-JavaScript/blob/master/CHANGELOG.md). -- Added `onChannelMemberCountChanged` and `onChannelParticipantCountChanged` in `ChannelHandler`. -- Changed `markAsDelivered` policy to remove rate limit timer. -- Improved stability. +- Added `AppleCriticalAlertOptions` interface. +- Added `appleCriticalAlertOptions` in `BaseMessage`, `UserMessageParams`, `FileMessageParams`, `ScheduledUserMessage`, and `ScheduledUserMessageParams`. +- Downgraded log level from `ERROR` to `DEBUG` for all internal API calls. diff --git a/SendBird.d.ts b/SendBird.d.ts index 55c9901..25ad5c4 100644 --- a/SendBird.d.ts +++ b/SendBird.d.ts @@ -1,5 +1,5 @@ /** - * Type Definitions for Sendbird SDK v3.0.147 + * Type Definitions for Sendbird SDK v3.0.148 * homepage: https://sendbird.com/ * git: https://github.com/sendbird/Sendbird-SDK-JavaScript */ @@ -395,6 +395,7 @@ declare namespace SendBird { parentMessageText: string; threadInfo: ThreadInfo; ogMetaData: OGMetaData; + appleCriticalAlertOptions: AppleCriticalAlertOptions; isEqual(target: BaseMessageInstance): boolean; isIdentical(target: BaseMessageInstance): boolean; @@ -462,6 +463,13 @@ declare namespace SendBird { detail: {}; } + interface AppleCriticalAlertOptions { + name: string; + volume: number; + + serialize(): Object; + } + interface UserMessageParams { new(): UserMessageParams; message: string; @@ -482,6 +490,7 @@ declare namespace SendBird { metaArrayKeys: Array; pushNotificationDeliveryOption: 'default' | 'suppress'; parentMessageId: number; + appleCriticalAlertOptions: AppleCriticalAlertOptions; } interface UserMessage extends BaseMessageInstance { messageType: 'user'; @@ -525,6 +534,7 @@ declare namespace SendBird { metaArrayKeys: Array; pushNotificationDeliveryOption: 'default' | 'suppress'; parentMessageId: number; + appleCriticalAlertOptions: AppleCriticalAlertOptions; } interface FileMessage extends BaseMessageInstance { messageType: 'file'; @@ -1729,6 +1739,7 @@ declare namespace SendBird { translationTargetLanguages: Array; errorMessage: string; errorCode: number; + appleCriticalAlertOptions: AppleCriticalAlertOptions; isGroupChannel(): boolean; isOpenChannel(): boolean; @@ -1783,6 +1794,7 @@ declare namespace SendBird { min: number; timezone: string; scheduledDateTimeString: string; + appleCriticalAlertOptions: AppleCriticalAlertOptions; setSchedule(year: number, month: number, day: number, hour: number, min: number, timezone: string): void; } diff --git a/SendBird.min.js b/SendBird.min.js index d420ad3..f3eb605 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.147 + * Sendbird JavaScript SDK v3.0.148 */ -!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(U,b,r){"use strict";function Ne(e){return(Ne="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);t=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}}}}U=U&&Object.prototype.hasOwnProperty.call(U,"default")?U.default:U,b=b&&Object.prototype.hasOwnProperty.call(b,"default")?b.default:b,r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;var Re=function(){function e(){v(this,e)}return s(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return"3.0.147"}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}]),e}(),_={},m=new WeakMap,Oe=function(){function t(){var e=0this.reconnectParams.retryCount){for(var d in this.disconnect({clearSession:!1,err:new Te("Websocket connection failed.",Te.WEBSOCKET_CONNECTION_FAILED)},null),this.reconnectCount=0,this.sb.connectionHandlers){this.sb.connectionHandlers[d].onReconnectFailed()}return this.sb.connecting=!1,this.sb.reconnecting=!1,this.sb.isReconnectingOnError=!1,void this.sb.ConnectionManager.errorAllReadyHandler()}this.sb.onReconnectTimerCancel=function(){a.reconnectCount=0},this.sb.reconnectTimer=setTimeout(function(){a.sb.reconnectTimer=null,a.sb.onReconnectTimerCancel=null,a.client&&a.client.disconnect(!0);var e=new j.ConnectionHandler;a.client=new j(a.sb,e),a.sb.loginHandler=function(e,n){if(e)e.isSessionKeyExpiredError?l.refresh(function(){}):(clearTimeout(a.sb.reconnectTimer),a.sb.reconnectTimer=null,a.reconnect(i,!1));else{for(var t in a.reconnectCount=0,a.sb.connecting=!1,a.sb.reconnecting=!1,a.sb.isReconnectingOnError=!1,a.sb.connectionHandlers){a.sb.connectionHandlers[t].onReconnectSucceeded()}if(a.sb.ConnectionManager.processAllReadyHandler(null),a.sb.isReconnectingOnError)for(var r in a.sb.ConnectionManager.networkHandlers)a.sb.ConnectionManager.networkHandlers[r].onReconnected();Object.keys(u.enteredChannels).forEach(function(r){u.enteredChannels[r].enter(function(e,n){if(e){var t=a.cls.FileMessageQueue;delete u.enteredChannels[r],t.delete(r)}})})}},e.onOpen=function(){Me.debug("Reconnect: `WebSocketClient.ConnectionHandler.onOpen` called."),a.sb.loginTimer=setTimeout(function(){Me.debug("Reconnect: `loginTimer` timeout."),a.sb.loginTimer=null,a.reconnect(i,!0)},a.sb.Options.websocketResponseTimeout),a.sb.onLoginTimerCancel=null,a.sb.reconnecting=!1},e.onMessage=function(e){o.onRawCommandReceived(e)},e.onError=function(e){Me.debug("Reconnect: `WebSocketClient.ConnectionHandler.onError` called.",e),a.sb.isReconnectingOnError=!0,a.sb.ConnectionManager.errorAllReadyHandler(),a.reconnect(i,!0)},e.onClose=function(){Me.debug("Reconnect: `WebSocketClient.ConnectionHandler.onClose` called."),a.sb.reconnecting=!1},s.checkRouting(function(e,n){e?a.reconnect(i,!0):(a.sb.getCurrentApiHost()!==n.apiHost&&s.get("/",null,function(){}),a.client.connect(i,null,n.wsHost))})},this.reconnectDelay)}}},{key:"disconnect",value:function(e,n){var t=Oe.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.client&&(this.reconnectCount=0,this.client.disconnect(!0),this.client=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 C)}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)})}},{key:"isConnected",get:function(){return this.client&&this.client.getConnectionState()===this.sb.ConnectionState.OPEN}}]),n}(),z=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?Ne(e)===n||"array"===n&&Array.isArray(e)||"file"===n&&Le.isFile(e)||"null"===n&&null===e||"date"===n&&e instanceof Date:"function"==typeof n?e instanceof n:"object"===Ne(n)&&-1n.updatedAt&&(n.value=t,n.updatedAt=i,n.isRemoved=!1):a[e]={value:t,updatedAt:i,isRemoved:!1}})}},{key:"_markAsDeletedCachedMetaData",value:function(e,t){var r=ae.get(this);e.forEach(function(e){var n=r[e];n?t>n.updatedAt&&(n.isRemoved=!0,n.updatedAt=t):r[e]={value:null,updatedAt:t,isRemoved:!0}})}},{key:"_refreshMetaData",value:function(n,t){var r={};Object.keys(n).forEach(function(e){r[e]={value:n[e],updatedAt:t,isRemoved:!1}}),ae.set(this,r)}},{key:"isGroupChannel",value:function(){var e=pe.get(this._iid).BaseChannel;return this.channelType===e.CHANNEL_TYPE_GROUP}},{key:"isOpenChannel",value:function(){var e=pe.get(this._iid).BaseChannel;return this.channelType===e.CHANNEL_TYPE_OPEN}},{key:"createOperatorListQuery",value:function(){return new(pe.get(this._iid).OperatorListQuery)(this)}},{key:"createMessageListQuery",value:function(){return new(pe.get(this._iid).MessageListQuery)(this)}},{key:"createPreviousMessageListQuery",value:function(){return new(pe.get(this._iid).PreviousMessageListQuery)(this)}},{key:"serialize",value:function(){return $.serialize(this,function(e){if(null!==e.lastMessage&&"object"===Ne(e.lastMessage)){var n=e.lastMessage;n.hasOwnProperty("_sender")&&(n.sender=n._sender,delete n._sender,e.lastMessage=n)}e.hasOwnProperty("_messageOffsetTimestamp")&&(e.messageOffsetTimestamp=e._messageOffsetTimestamp,delete e._messageOffsetTimestamp)})}},{key:"getMessageChangeLogsByTimestamp",value:function(e,n,t,r){var a,s=this,i=B(z.parse(arguments,[new z({type:"number",constraint:function(e){return 0<=e}}),new z({type:"boolean",optional:!0,defaultValue:!1}),new z({type:"boolean",optional:!0,defaultValue:!1}),new z({type:"callback"})]),5);return a=i[0],e=i[1],n=i[2],t=i[3],r=i[4],Z(this._iid,function(i){a?i(a,null):Oe.get(s._iid).container.apiClient.getMessageChangeLogs({channelUrl:s.url,ts:e,token:null,isOpenChannel:s.isOpenChannel(),includeMetaArray:n,includeReactions:t},function(e,n){var t=null;if(!e){var r=pe.get(s._iid).BaseChannel;t={updatedMessages:n.updated.map(function(e){return r.buildMessage(e,s)}),deletedMessageIds:n.deleted.map(function(e){return parseInt(e.message_id)}),hasMore:n.has_more,token:n.next}}i(e,t)})},r)}},{key:"getMessageChangeLogsByToken",value:function(e,n,t,r){var a,s=this,i=B(z.parse(arguments,[new z({type:"string",nullable:!0}),new z({type:"boolean",optional:!0,defaultValue:!1}),new z({type:"boolean",optional:!0,defaultValue:!1}),new z({type:"callback"})]),5);return a=i[0],e=i[1],n=i[2],t=i[3],r=i[4],Z(this._iid,function(i){a?i(a,null):Oe.get(s._iid).container.apiClient.getMessageChangeLogs({channelUrl:s.url,ts:null,token:e,isOpenChannel:s.isOpenChannel(),includeMetaArray:n,includeReactions:t},function(e,n){var t=null;if(!e){var r=pe.get(s._iid).BaseChannel;t={updatedMessages:n.updated.map(function(e){return r.buildMessage(e,s)}),deletedMessageIds:n.deleted.map(function(e){return parseInt(e.message_id)}),hasMore:n.has_more,token:n.next}}i(e,t)})},r)}},{key:"getMessageChangeLogsSinceToken",value:function(e,n,t){var i,a=this,r=pe.get(this._iid),s=r.BaseChannel,o=r.MessageChangeLogsParams,l=B(z.parse(arguments,[new z({type:"string",nullable:!0}),new z({type:o}),new z({type:"callback"})]),4);return i=l[0],e=l[1],n=l[2],t=l[3],Z(this._iid,function(r){i?r(i,null):Oe.get(a._iid).container.apiClient.getMessageChangeLogs(g({channelUrl:a.url,ts:null,token:e,isOpenChannel:a.isOpenChannel()},n),function(e,n){var t=null;e||(t={updatedMessages:n.updated.map(function(e){return s.buildMessage(e,a)}),deletedMessageIds:n.deleted.map(function(e){return parseInt(e.message_id)}),hasMore:n.has_more,token:n.next}),r(e,t)})},t)}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e,n,t){var i,a=this,r=pe.get(this._iid),s=r.BaseChannel,o=r.MessageChangeLogsParams,l=B(z.parse(arguments,[new z({type:"number",constraint:function(e){return 0<=e}}),new z({type:o}),new z({type:"callback"})]),4);return i=l[0],e=l[1],n=l[2],t=l[3],Z(this._iid,function(r){i?r(i,null):Oe.get(a._iid).container.apiClient.getMessageChangeLogs(g({channelUrl:a.url,timestamp:e,token:null,isOpenChannel:a.isOpenChannel()},n),function(e,n){var t=null;e||(t={updatedMessages:n.updated.map(function(e){return s.buildMessage(e,a)}),deletedMessageIds:n.deleted.map(function(e){return parseInt(e.message_id)}),hasMore:n.has_more,token:n.next}),r(e,t)})},t)}},{key:"getMyMutedInfo",value:function(e){var n=this;return Z(this._iid,function(r){var e=qn.getInstance(n._iid);Oe.get(n._iid).container.apiClient.getMyMutedInfo({channelUrl:n.url,userId:e.currentUser?e.currentUser.userId:null,isGroupChannel:n.isGroupChannel()},function(e,n){var t=null;e||(t={isMuted:n.is_muted,startAt:n.start_at,endAt:n.end_at,remainingDuration:n.remaining_duration,description:n.description}),r(e,t)})},e)}},{key:"_parseMessageListParams",value:function(e){for(var n=new(pe.get(this._iid).MessageListParams),t=null,r=!1,i=0,a=0,s=!1,o="",l="",u=null,c=!1,d=!1,h=null,p=arguments.length,f=new Array(1m.ts){if(m.all!==A.unread_cnt.all&&(S=!0),m.all=0<=A.unread_cnt.all?A.unread_cnt.all:0,A.unread_cnt.custom_types)for(var N in A.unread_cnt.custom_types)m.custom_types[N]!==A.unread_cnt.custom_types[N]&&(S=!0),m.custom_types[N]=A.unread_cnt.custom_types[N];S=S&&0=G.createAt,a=v.sb.currentUser;a&&x&&(a.nickname!==G._sender.nickname&&(a.nickname=G._sender.nickname),a.plainProfileUrl!==G._sender.plainProfileUrl&&(a.plainProfileUrl=G._sender.plainProfileUrl),Le.deepEqual(a.metaData,G._sender.metaData)||(a.metaData=G._sender.metaData));var s=!1,o=!1;if(!x&&!i&&A&&A.hasOwnProperty("old_values")){var l=A.old_values.mention_type||G.mentionType,u=A.old_values.mentioned_user_ids||G.mentionedUsers.map(function(e){return e.userId});if(l===C.MentionType.USERS&&G.mentionType===C.MentionType.USERS){for(var c=!1,d=!1,h=0;h=be.get(this)&&(be.set(this,t),r=n!==this.joinedMemberCount||e!==this.memberCount,this.memberCount=e,this.joinedMemberCount=n),r}},{key:"hide",value:function(i,a,e){var n,s=this,t=B(z.parse(arguments,[new z({type:"boolean",optional:!0,defaultValue:!1}),new z({type:"boolean",optional:!0,defaultValue:!0}),new z({type:"callback"})]),4);return n=t[0],i=t[1],a=t[2],e=t[3],Z(this._iid,function(r){n?r(n,null):Oe.get(s._iid).container.apiClient.hideGroupChannel({channelUrl:s.url,hidePreviousMessages:i,allowAutoUnhide:a},function(e,n){if(!e){var t=pe.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 Z(this._iid,function(r){Oe.get(i._iid).container.apiClient.unhideGroupChannel({channelUrl:i.url},function(e,n){if(!e){var t=pe.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 i=this;return Z(this._iid,function(r){Oe.get(i._iid).container.apiClient.freeze({channelUrl:i.url,isGroupChannel:!0,freezing:!0},function(e,n){if(!e){var t=pe.get(i._iid).GroupChannel;i.isFrozen=!0,t.cachedChannels[i.url]=i}r(e,null)})},e)}},{key:"unfreeze",value:function(e){var i=this;return Z(this._iid,function(r){Oe.get(i._iid).container.apiClient.freeze({channelUrl:i.url,isGroupChannel:!0,freezing:!1},function(e,n){if(!e){var t=pe.get(i._iid).GroupChannel;i.isFrozen=!1,t.cachedChannels[i.url]=i}r(e,null)})},e)}},{key:"delete",value:function(e){var r=this;return Z(this._iid,function(t){Oe.get(r._iid).container.apiClient.deleteGroupChannel({channelUrl:r.url},function(e,n){e||pe.get(r._iid).GroupChannel.removeCachedChannel(r.url);t(e,n)})},e)}},{key:"markAsRead",value:function(){var i=this,e=pe.get(this._iid).Command,a=qn.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.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=pe.get(this._iid).Command.bTypeStart({channelUrl:this.url,time:r.start});e.sendCommand(i,null)}}},{key:"endTyping",value:function(){var e=qn.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=pe.get(this._iid).Command.bTypeEnd({channelUrl:this.url,time:r.end});e.sendCommand(i,null)}}},{key:"invalidateTypingStatus",value:function(){var e=Ee.get(this),n=(new Date).getTime(),t=!1;for(var r in e){1e4<=n-e[r].ts&&(delete e[r],t=!0)}return t}},{key:"getTypingMembers",value:function(){var e=Ee.get(this),n=[];for(var t in e){var r=this.memberMap[t];r&&n.push(r)}return n}},{key:"getTypingUsers",value:function(){var e=Ee.get(this),n=[];for(var t in e){var r=e[t].user;n.push(r)}return n}},{key:"updateTypingStatus",value:function(e,n){var t=Ee.get(this);n?t[e.userId]={user:e,ts:(new Date).getTime()}:delete t[e.userId]}},{key:"isTyping",value:function(){var e=Ee.get(this);return 0!==Object.keys(e).length}},{key:"registerScheduledUserMessage",value:function(e,n){var t,a=this,r=pe.get(this._iid),s=r.ScheduledUserMessage,i=r.ScheduledUserMessageParams,o=B(z.parse(arguments,[new z({type:i,constraint:function(e){return"string"==typeof e.message&&"string"==typeof e._getScheduleString()}}),new z({type:"callback"})]),3);return t=o[0],e=o[1],n=o[2],Z(this._iid,function(i){t?i(t,null):Oe.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=qn.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 Z(this._iid,function(r){Oe.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 Z(this._iid,function(t){var r=pe.get(i._iid).GroupChannel;Oe.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 Z(this._iid,function(r){Oe.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){Me.debug(e)}i.myPushTriggerOption=t}r(e,t)})},e)}},{key:"setMyPushTriggerOption",value:function(e,n){var t,i=this,r=pe.get(this._iid).GroupChannel,a=B(z.parse(arguments,[new z({type:r.PushTriggerOption}),new z({type:"callback"})]),3);return t=a[0],e=a[1],n=a[2],Z(this._iid,function(r){t?r(t,null):Oe.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){Me.debug(e)}i.myPushTriggerOption=t}r(e,t)})},n)}},{key:"setMyCountPreference",value:function(e,n){var t,i=this,a=pe.get(this._iid).GroupChannel,r=B(z.parse(arguments,[new z({type:a.CountPreference}),new z({type:"callback"})]),3);return t=r[0],e=r[1],n=r[2],Z(this._iid,function(r){t?r(t,null):Oe.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 Z(this._iid,function(r){Oe.get(i._iid).container.apiClient.resetMyHistory({channelUrl:i.url},function(e,n){if(!e&&n.hasOwnProperty("ts_message_offset")){var t=pe.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=pe.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=$.deserialize(e),d=null!=(n=c.lastMessage)&&"object"===Ne(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;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,is_hidden:c.isHidden,is_ephemeral:c.isEphemeral,is_muted:c.myMutedState,is_push_enabled:c.isPushEnabled,freeze:c.isFrozen,unread_message_count:c.unreadMessageCount,unread_mention_count:c.unreadMentionCount,push_trigger_option:c.myPushTriggerOption,count_preference:c.myCountPreference,hidden_state:c.hiddenState,member_count:c.memberCount,joined_member_count:c.joinedMemberCount,member_state:c.myMemberState,my_role:c.myRole,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:d,created_by:null!==c.creator&&void 0!==c.creator&&"object"===Ne(c.creator)?r.objectify(c.creator):null,inviter:null!==c.inviter&&void 0!==c.inviter&&"object"===Ne(c.inviter)?r.objectify(c.inviter):null})}},{key:"upsert",value:function(e){var n=pe.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=pe.get(this._iid),t=n.GroupChannel,r=n.FileMessageQueue;t.cachedChannels[e]&&delete t.cachedChannels[e],r.delete(e)}},{key:"clearCache",value:function(){ve[this._iid]={},pe.get(this._iid).FileMessageQueue.clear()}},{key:"getChannel",value:function(n,e){var t,r,i=B(z.parse(arguments,[new z({type:"string",constraint:function(e){return 0=xe.get(this)&&(xe.set(this,n),t=e!==this.participantCount,this.participantCount=e),t}},{key:"delete",value:function(e){var r=this;return Z(this._iid,function(t){Oe.get(r._iid).container.apiClient.deleteOpenChannel({channelUrl:r.url},function(e,n){e||(delete pe.get(r._iid).OpenChannel.cachedChannels[r.url],pe.get(r._iid).FileMessageQueue.delete(r.url));t(e,n)})},e)}}],[{key:"buildFromSerializedData",value:function(e){var n=pe.get(this._iid),t=n.User,r=n.OpenChannel,i=$.deserialize(e);return new r({channel_url:i.url,name:i.name,cover_url:i.coverUrl,data:i.data,custom_type:i.customType,created_at:i.createdAt/1e3,freeze:i.isFrozen,is_ephemeral:i.isEphemeral,participant_count:i.participantCount,operators:i.operators.map(function(e){return t.objectify(e)})})}},{key:"getChannel",value:function(n,e){var t,r,i=B(z.parse(arguments,[new z({type:"string",constraint:function(e){return 0e.length)&&(n=e.length);for(var t=0,r=new Array(n);t=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}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 i,a=!0,s=!1;return{s:function(){t=e[Symbol.iterator]()},n:function(){var e=t.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==t.return||t.return()}finally{if(s)throw i}}}}E=E&&Object.prototype.hasOwnProperty.call(E,"default")?E.default:E,b=b&&Object.prototype.hasOwnProperty.call(b,"default")?b.default:b,r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;var Ce=function(){function e(){c(this,e)}return o(e,null,[{key:"OS_VERSION",get:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}},{key:"SDK_VERSION",get:function(){return"3.0.148"}},{key:"SDK_MAJOR_VERSION",get:function(){return e.SDK_VERSION.split(".")[0]}},{key:"DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL",get:function(){return 100}},{key:"INTERNAL_CALL",get:function(){return"ic"}}]),e}(),m={},v=new WeakMap,Ee=function(){function t(){var e=0this.reconnectParams.retryCount){for(var c in this.disconnect({clearSession:!1,err:new be("Websocket connection failed.",be.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(){a.reconnectCount=0},this.sb.reconnectTimer=setTimeout(function(){a.sb.reconnectTimer=null,a.sb.onReconnectTimerCancel=null,a.client&&a.client.disconnect(!0);var e=new x.ConnectionHandler;a.client=new x(a.sb,e),a.sb.loginHandler=function(e,n){if(e)e.isSessionKeyExpiredError?o.refresh(function(){}):(clearTimeout(a.sb.reconnectTimer),a.sb.reconnectTimer=null,a.reconnect(i,!1));else{for(var t in a.reconnectCount=0,a.sb.connecting=!1,a.sb.reconnecting=!1,a.sb.isReconnectingOnError=!1,a.sb.connectionHandlers)a.sb.connectionHandlers[t].onReconnectSucceeded();if(a.sb.ConnectionManager.processAllReadyHandler(null),a.sb.isReconnectingOnError)for(var r in a.sb.ConnectionManager.networkHandlers)a.sb.ConnectionManager.networkHandlers[r].onReconnected();Object.keys(l.enteredChannels).forEach(function(t){l.enteredChannels[t].enter(function(e,n){e&&(e=a.cls.FileMessageQueue,delete l.enteredChannels[t],e.delete(t))})})}},e.onOpen=function(){Ue.debug("Reconnect: `WebSocketClient.ConnectionHandler.onOpen` called."),a.sb.loginTimer=setTimeout(function(){Ue.debug("Reconnect: `loginTimer` timeout."),a.sb.loginTimer=null,a.reconnect(i,!0)},a.sb.Options.websocketResponseTimeout),a.sb.onLoginTimerCancel=null,a.sb.reconnecting=!1},e.onMessage=function(e){s.onRawCommandReceived(e)},e.onError=function(e){Ue.debug("Reconnect: `WebSocketClient.ConnectionHandler.onError` called.",e),a.sb.isReconnectingOnError=!0,a.sb.ConnectionManager.errorAllReadyHandler(),a.reconnect(i,!0)},e.onClose=function(){Ue.debug("Reconnect: `WebSocketClient.ConnectionHandler.onClose` called."),a.sb.reconnecting=!1},r.checkRouting(function(e,n){e?a.reconnect(i,!0):(a.sb.getCurrentApiHost()!==n.apiHost&&r.get("/",null,function(){}),a.client.connect(i,null,n.wsHost))})},this.reconnectDelay)}}},{key:"disconnect",value:function(e,n){var t=Ee.get(this.sb._iid),r=t.container.ackStateMap,i=this.cls,a=i.GroupChannel,s=i.OpenChannel,i=e.clearSession,e=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.client&&(this.reconnectCount=0,this.client.disconnect(!0),this.client=null),i){for(var o in s.clearEnteredChannels(),s.clearCache(),a.clearCache(),this.sb.globalTimer&&(clearInterval(this.sb.globalTimer),this.sb.globalTimer=null),r)clearTimeout(r[o].timer);this.sb.currentUser=null,t.set("ackStateMap",{}),t.set("subscribedUnreadMessageCount",{all:0,custom_types:{},ts:0}),t.set("auth",new C)}e&&(this.flushConnectionCallbacks(e,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 u(e){var n=e.type,t=e.nullable,r=void 0!==t&&t,i=e.optional,a=void 0!==i&&i,s=e.optionalIf,t=void 0===s?null:s,i=e.ignoreIf,s=void 0===i?null:i,i=e.defaultValue,i=void 0===i?null:i,e=e.constraint,e=void 0===e?null:e;c(this,u),this.type=n,this.nullable=r,this.optional=a,this.optionalIf=t,this.ignoreIf=s,this.defaultValue=i,this.constraint=e}return o(u,[{key:"isMatchingType",value:function(t){function n(e,n){return"string"==typeof n?me(e)===n||"array"===n&&Array.isArray(e)||"file"===n&&Ae.isFile(e)||"null"===n&&null===e||"date"===n&&e instanceof Date:"function"==typeof n?e instanceof n:"object"===me(n)&&-1n.updatedAt&&(n.value=t,n.updatedAt=i,n.isRemoved=!1):a[e]={value:t,updatedAt:i,isRemoved:!1}})}},{key:"_markAsDeletedCachedMetaData",value:function(e,t){var r=he.get(this);e.forEach(function(e){var n=r[e];n?t>n.updatedAt&&(n.isRemoved=!0,n.updatedAt=t):r[e]={value:null,updatedAt:t,isRemoved:!0}})}},{key:"_refreshMetaData",value:function(n,t){var r={};Object.keys(n).forEach(function(e){r[e]={value:n[e],updatedAt:t,isRemoved:!1}}),he.set(this,r)}},{key:"isGroupChannel",value:function(){var e=j.get(this._iid).BaseChannel;return this.channelType===e.CHANNEL_TYPE_GROUP}},{key:"isOpenChannel",value:function(){var e=j.get(this._iid).BaseChannel;return this.channelType===e.CHANNEL_TYPE_OPEN}},{key:"createOperatorListQuery",value:function(){return new(j.get(this._iid).OperatorListQuery)(this)}},{key:"createMessageListQuery",value:function(){return new(j.get(this._iid).MessageListQuery)(this)}},{key:"createPreviousMessageListQuery",value:function(){return new(j.get(this._iid).PreviousMessageListQuery)(this)}},{key:"serialize",value:function(){return se.serialize(this,function(e){var n;null===e.lastMessage||"object"!==me(e.lastMessage)||(n=e.lastMessage).hasOwnProperty("_sender")&&(n.sender=n._sender,delete n._sender,e.lastMessage=n),e.hasOwnProperty("_messageOffsetTimestamp")&&(e.messageOffsetTimestamp=e._messageOffsetTimestamp,delete e._messageOffsetTimestamp)})}},{key:"getMessageChangeLogsByTimestamp",value:function(e,n,t,r){var a=this,i=T(W.parse(arguments,[new W({type:"number",constraint:function(e){return 0<=e}}),new W({type:"boolean",optional:!0,defaultValue:!1}),new W({type:"boolean",optional:!0,defaultValue:!1}),new W({type:"callback"})]),5),s=i[0];return e=i[1],n=i[2],t=i[3],r=i[4],ae(this._iid,function(i){s?i(s,null):Ee.get(a._iid).container.apiClient.getMessageChangeLogs({channelUrl:a.url,ts:e,token:null,isOpenChannel:a.isOpenChannel(),includeMetaArray:n,includeReactions:t},function(e,n){var t,r=null;e||(t=j.get(a._iid).BaseChannel,r={updatedMessages:n.updated.map(function(e){return t.buildMessage(e,a)}),deletedMessageIds:n.deleted.map(function(e){return parseInt(e.message_id)}),hasMore:n.has_more,token:n.next}),i(e,r)})},r)}},{key:"getMessageChangeLogsByToken",value:function(e,n,t,r){var a=this,i=T(W.parse(arguments,[new W({type:"string",nullable:!0}),new W({type:"boolean",optional:!0,defaultValue:!1}),new W({type:"boolean",optional:!0,defaultValue:!1}),new W({type:"callback"})]),5),s=i[0];return e=i[1],n=i[2],t=i[3],r=i[4],ae(this._iid,function(i){s?i(s,null):Ee.get(a._iid).container.apiClient.getMessageChangeLogs({channelUrl:a.url,ts:null,token:e,isOpenChannel:a.isOpenChannel(),includeMetaArray:n,includeReactions:t},function(e,n){var t,r=null;e||(t=j.get(a._iid).BaseChannel,r={updatedMessages:n.updated.map(function(e){return t.buildMessage(e,a)}),deletedMessageIds:n.deleted.map(function(e){return parseInt(e.message_id)}),hasMore:n.has_more,token:n.next}),i(e,r)})},r)}},{key:"getMessageChangeLogsSinceToken",value:function(e,n,t){var i=this,r=j.get(this._iid),a=r.BaseChannel,r=r.MessageChangeLogsParams,r=T(W.parse(arguments,[new W({type:"string",nullable:!0}),new W({type:r}),new W({type:"callback"})]),4),s=r[0];return e=r[1],n=r[2],t=r[3],ae(this._iid,function(r){s?r(s,null):Ee.get(i._iid).container.apiClient.getMessageChangeLogs(g({channelUrl:i.url,ts:null,token:e,isOpenChannel:i.isOpenChannel()},n),function(e,n){var t=null;e||(t={updatedMessages:n.updated.map(function(e){return a.buildMessage(e,i)}),deletedMessageIds:n.deleted.map(function(e){return parseInt(e.message_id)}),hasMore:n.has_more,token:n.next}),r(e,t)})},t)}},{key:"getMessageChangeLogsSinceTimestamp",value:function(e,n,t){var i=this,r=j.get(this._iid),a=r.BaseChannel,r=r.MessageChangeLogsParams,r=T(W.parse(arguments,[new W({type:"number",constraint:function(e){return 0<=e}}),new W({type:r}),new W({type:"callback"})]),4),s=r[0];return e=r[1],n=r[2],t=r[3],ae(this._iid,function(r){s?r(s,null):Ee.get(i._iid).container.apiClient.getMessageChangeLogs(g({channelUrl:i.url,timestamp:e,token:null,isOpenChannel:i.isOpenChannel()},n),function(e,n){var t=null;e||(t={updatedMessages:n.updated.map(function(e){return a.buildMessage(e,i)}),deletedMessageIds:n.deleted.map(function(e){return parseInt(e.message_id)}),hasMore:n.has_more,token:n.next}),r(e,t)})},t)}},{key:"getMyMutedInfo",value:function(e){var n=this;return ae(this._iid,function(r){var e=it.getInstance(n._iid);Ee.get(n._iid).container.apiClient.getMyMutedInfo({channelUrl:n.url,userId:e.currentUser?e.currentUser.userId:null,isGroupChannel:n.isGroupChannel()},function(e,n){var t=null;e||(t={isMuted:n.is_muted,startAt:n.start_at,endAt:n.end_at,remainingDuration:n.remaining_duration,description:n.description}),r(e,t)})},e)}},{key:"_parseMessageListParams",value:function(e){for(var n=new(j.get(this._iid).MessageListParams),t=null,r=!1,i=0,a=0,s=!1,o="",l="",u=null,c=!1,d=!1,h=null,p=arguments.length,g=new Array(1v.ts){if(v.all!==b.unread_cnt.all&&(U=!0),v.all=0<=b.unread_cnt.all?b.unread_cnt.all:0,b.unread_cnt.custom_types)for(var S in b.unread_cnt.custom_types)v.custom_types[S]!==b.unread_cnt.custom_types[S]&&(U=!0),v.custom_types[S]=b.unread_cnt.custom_types[S];U=U&&0=F.createAt,t=g.sb.currentUser;t&&D&&(t.nickname!==F._sender.nickname&&(t.nickname=F._sender.nickname),t.plainProfileUrl!==F._sender.plainProfileUrl&&(t.plainProfileUrl=F._sender.plainProfileUrl),Ae.deepEqual(t.metaData,F._sender.metaData)||(t.metaData=F._sender.metaData));var r,t=!1,i=!1;if(!D&&!n&&b&&b.hasOwnProperty("old_values")){var n=b.old_values.mention_type||F.mentionType,a=b.old_values.mentioned_user_ids||F.mentionedUsers.map(function(e){return e.userId});if(n===y.MentionType.USERS&&F.mentionType===y.MentionType.USERS){for(var s=!1,o=!1,l=0;l=Le.get(this)&&(Le.set(this,t),r=n!==this.joinedMemberCount||e!==this.memberCount,this.memberCount=e,this.joinedMemberCount=n),r}},{key:"hide",value:function(i,a,e){var s=this,n=T(W.parse(arguments,[new W({type:"boolean",optional:!0,defaultValue:!1}),new W({type:"boolean",optional:!0,defaultValue:!0}),new W({type:"callback"})]),4),t=n[0];return i=n[1],a=n[2],e=n[3],ae(this._iid,function(r){t?r(t,null):Ee.get(s._iid).container.apiClient.hideGroupChannel({channelUrl:s.url,hidePreviousMessages:i,allowAutoUnhide:a},function(e,n){var t;e||(t=j.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 ae(this._iid,function(r){Ee.get(i._iid).container.apiClient.unhideGroupChannel({channelUrl:i.url},function(e,n){var t;e||(t=j.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 i=this;return ae(this._iid,function(r){Ee.get(i._iid).container.apiClient.freeze({channelUrl:i.url,isGroupChannel:!0,freezing:!0},function(e,n){var t;e||(t=j.get(i._iid).GroupChannel,i.isFrozen=!0,t.cachedChannels[i.url]=i),r(e,null)})},e)}},{key:"unfreeze",value:function(e){var i=this;return ae(this._iid,function(r){Ee.get(i._iid).container.apiClient.freeze({channelUrl:i.url,isGroupChannel:!0,freezing:!1},function(e,n){var t;e||(t=j.get(i._iid).GroupChannel,i.isFrozen=!1,t.cachedChannels[i.url]=i),r(e,null)})},e)}},{key:"delete",value:function(e){var r=this;return ae(this._iid,function(t){Ee.get(r._iid).container.apiClient.deleteGroupChannel({channelUrl:r.url},function(e,n){e||j.get(r._iid).GroupChannel.removeCachedChannel(r.url),t(e,n)})},e)}},{key:"markAsRead",value:function(){var i=this,e=j.get(this._iid).Command,a=it.getInstance(this._iid),e=e.bRead({channelUrl:this.url});a.sendCommand(e,function(e,n){var t;if(a.getErrorFirstCallback()&&(n=(t=[e,n])[0],e=t[1]),!n&&a.currentUser&&(i.updateReadReceipt(a.currentUser.userId,e.getJsonElement().ts),0=e.createdAt&&r.push(a)}return r}return[]}},{key:"getUnreadMembers",value:function(e){var n=1=t&&(r.end=0,r.start=n,r=j.get(this._iid).Command.bTypeStart({channelUrl:this.url,time:r.start}),e.sendCommand(r,null))}},{key:"endTyping",value:function(){var e=it.getInstance(this._iid),n=(new Date).getTime(),t=e.Options.typingIndicatorThrottle;("number"!=typeof t||t<1e3||9e3=t&&(r.start=0,r.end=n,r=j.get(this._iid).Command.bTypeEnd({channelUrl:this.url,time:r.end}),e.sendCommand(r,null))}},{key:"invalidateTypingStatus",value:function(){var e,n=Te.get(this),t=(new Date).getTime(),r=!1;for(e in n)1e4<=t-n[e].ts&&(delete n[e],r=!0);return r}},{key:"getTypingMembers",value:function(){var e,n=[];for(e in Te.get(this)){var t=this.memberMap[e];t&&n.push(t)}return n}},{key:"getTypingUsers",value:function(){var e,n=Te.get(this),t=[];for(e in n){var r=n[e].user;t.push(r)}return t}},{key:"updateTypingStatus",value:function(e,n){var t=Te.get(this);n?t[e.userId]={user:e,ts:(new Date).getTime()}:delete t[e.userId]}},{key:"isTyping",value:function(){var e=Te.get(this);return 0!==Object.keys(e).length}},{key:"registerScheduledUserMessage",value:function(e,n){var i=this,t=j.get(this._iid),a=t.ScheduledUserMessage,t=t.ScheduledUserMessageParams,t=T(W.parse(arguments,[new W({type:t,constraint:function(e){return"string"==typeof e.message&&"string"==typeof e._getScheduleString()}}),new W({type:"callback"})]),3),s=t[0];return e=t[1],n=t[2],ae(this._iid,function(r){s?r(s,null):Ee.get(i._iid).container.apiClient.registerScheduledUserMessage({groupChannelParams:e,channelUrl:i.url,isOpenChannel:!1},function(e,n){var t=null;e||(t=new a(n),(n=it.getInstance(i._iid).currentUser)&&t._sender&&n.userId===t._sender.userId&&(n.nickname=t._sender.nickname,n.plainProfileUrl=t._sender.plainProfileUrl,n.metaData=t._sender.metaData)),r(e,t)})},n)}},{key:"getPushPreference",value:function(e){var i=this;return ae(this._iid,function(r){Ee.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 ae(this._iid,function(t){var r=j.get(i._iid).GroupChannel;Ee.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 ae(this._iid,function(r){Ee.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){Ue.debug(e)}i.myPushTriggerOption=t}r(e,t)})},e)}},{key:"setMyPushTriggerOption",value:function(e,n){var i=this,t=j.get(this._iid).GroupChannel,t=T(W.parse(arguments,[new W({type:t.PushTriggerOption}),new W({type:"callback"})]),3),a=t[0];return e=t[1],n=t[2],ae(this._iid,function(r){a?r(a,null):Ee.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){Ue.debug(e)}i.myPushTriggerOption=t}r(e,t)})},n)}},{key:"setMyCountPreference",value:function(e,n){var i=this,a=j.get(this._iid).GroupChannel,t=T(W.parse(arguments,[new W({type:a.CountPreference}),new W({type:"callback"})]),3),s=t[0];return e=t[1],n=t[2],ae(this._iid,function(r){s?r(s,null):Ee.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 ae(this._iid,function(r){Ee.get(i._iid).container.apiClient.resetMyHistory({channelUrl:i.url},function(e,n){var t;!e&&n.hasOwnProperty("ts_message_offset")&&(t=j.get(i._iid).GroupChannel,i._messageOffsetTimestamp=n.ts_message_offset,t.cachedChannels[i.url]=i),r(e,n)})},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 Oe[this._iid]||(Oe[this._iid]={}),Oe[this._iid]}},{key:"buildFromSerializedData",value:function(e){var n=j.get(this._iid),t=n.User,r=n.Member,i=n.GroupChannel,a=n.BaseMessage,s=n.UserMessage,o=n.FileMessage,l=n.AdminMessage,n=se.deserialize(e),e=null!=(e=n.lastMessage)&&"object"===me(e)?e.messageType===a.MESSAGE_TYPE_USER?new s(s.objectify(g(g({},e),{},{channel:{url:e.channelUrl,channelType:e.channelType},user:e.sender,mentionedUsers:e.mentionedUsers}))):e.messageType===a.MESSAGE_TYPE_FILE?new o(o.objectify(g(g({},e),{},{channel:{url:e.channelUrl,channelType:e.channelType},user:e.sender,mentionedUsers:e.mentionedUsers}))):new l(l.objectify(g(g({},e),{},{channel:{url:e.channelUrl,channelType:e.channelType},mentionedUsers:e.mentionedUsers}))):null;return new i({channel_url:n.url,name:n.name,cover_url:n.coverUrl,data:n.data,custom_type:n.customType,invited_at:n.invitedAt,created_at:n.createdAt/1e3,is_access_code_required:n.isAccessCodeRequired,is_distinct:n.isDistinct,is_super:n.isSuper,is_broadcast:n.isBroadcast,is_public:n.isPublic,is_discoverable:n.isDiscoverable,is_hidden:n.isHidden,is_ephemeral:n.isEphemeral,is_muted:n.myMutedState,is_push_enabled:n.isPushEnabled,freeze:n.isFrozen,unread_message_count:n.unreadMessageCount,unread_mention_count:n.unreadMentionCount,push_trigger_option:n.myPushTriggerOption,count_preference:n.myCountPreference,hidden_state:n.hiddenState,member_count:n.memberCount,joined_member_count:n.joinedMemberCount,member_state:n.myMemberState,my_role:n.myRole,user_last_read:n.myLastRead,ts_message_offset:n.messageOffsetTimestamp,message_survival_seconds:n.messageSurvivalSeconds,read_receipt:n.cachedReadReceiptStatus,delivery_receipt:n.cachedDeliveryReceiptStatus,members:n.members.map(function(e){return r.objectify(g({user:e},e))}),last_message:e,created_by:null!==n.creator&&void 0!==n.creator&&"object"===me(n.creator)?t.objectify(n.creator):null,inviter:null!==n.inviter&&void 0!==n.inviter&&"object"===me(n.inviter)?t.objectify(n.inviter):null})}},{key:"upsert",value:function(e){var n,t=j.get(this._iid).GroupChannel,r=new t(e);return t.cachedChannels.hasOwnProperty(r.url)?(r.isEphemeral&&(n=t.cachedChannels[r.url],e.last_message=n.lastMessage,e.unread_message_count=n.unreadMessageCount),t.cachedChannels[r.url].update(e)):t.cachedChannels[r.url]=r,t.cachedChannels[r.url]}},{key:"removeCachedChannel",value:function(e){var n=j.get(this._iid),t=n.GroupChannel,n=n.FileMessageQueue;t.cachedChannels[e]&&delete t.cachedChannels[e],n.delete(e)}},{key:"clearCache",value:function(){Oe[this._iid]={},j.get(this._iid).FileMessageQueue.clear()}},{key:"getChannel",value:function(n,e){var t,r=T(W.parse(arguments,[new W({type:"string",constraint:function(e){return 0=xe.get(this)&&(xe.set(this,n),t=e!==this.participantCount,this.participantCount=e),t}},{key:"delete",value:function(e){var r=this;return ae(this._iid,function(t){Ee.get(r._iid).container.apiClient.deleteOpenChannel({channelUrl:r.url},function(e,n){e||(delete j.get(r._iid).OpenChannel.cachedChannels[r.url],j.get(r._iid).FileMessageQueue.delete(r.url)),t(e,n)})},e)}}],[{key:"cachedChannels",get:function(){return Be[this._iid]||(Be[this._iid]={}),Be[this._iid]}},{key:"enteredChannels",get:function(){return je[this._iid]||(je[this._iid]={}),je[this._iid]}},{key:"buildFromSerializedData",value:function(e){var n=j.get(this._iid),t=n.User,n=n.OpenChannel,e=se.deserialize(e);return new n({channel_url:e.url,name:e.name,cover_url:e.coverUrl,data:e.data,custom_type:e.customType,created_at:e.createdAt/1e3,freeze:e.isFrozen,is_ephemeral:e.isEphemeral,participant_count:e.participantCount,operators:e.operators.map(function(e){return t.objectify(e)})})}},{key:"getChannel",value:function(n,e){var t,r=T(W.parse(arguments,[new W({type:"string",constraint:function(e){return 0" ], diff --git a/package.json b/package.json index d38943a..d758c66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sendbird", - "version": "3.0.147", + "version": "3.0.148", "description": "Sendbird JavaScript SDK", "main": "SendBird.min.js", "dependencies": {