@evo/chat-core
Advanced tools
Comparing version 0.5.1 to 0.5.4
@@ -410,10 +410,11 @@ 'use strict'; | ||
var isTemporaryMessage = true; | ||
var updReceiveRoom = receiveRoom; | ||
var roomPath = [setInEntity, setInIndex]; | ||
var msgId = (0, _uuid2.default)(); | ||
var sendingMessage = (0, _utils.prepareMessage)(baseStore, msgId, roomIdent, body, platform, source, device, true); | ||
var sendingMessage = (0, _utils.prepareMessage)(baseStore, msgId, roomIdent, body, platform, source, device, isTemporaryMessage); | ||
updReceiveRoom = (0, _utils.insertMessage)(updReceiveRoom, sendingMessage); | ||
baseStore = baseStore.setIn(roomPath, updReceiveRoom); | ||
this.message && this.message(roomIdent, this.dataFormatter(_immutable2.default.fromJS(sendingMessage))); | ||
this.message && this.message(roomIdent, this.dataFormatter(sendingMessage)); | ||
@@ -427,14 +428,14 @@ return this.oSwindon.call('chat.send_message', [], { | ||
}).then(function (data) { | ||
sendingMessage.id = data.message_id; | ||
sendingMessage.isTemporaryMessage = false; | ||
sendingMessage = sendingMessage.set('id', data.message_id); | ||
sendingMessage = sendingMessage.set('isTemporaryMessage', false); | ||
updReceiveRoom = (0, _utils.updateMessageById)(baseStore.getIn(roomPath), msgId, sendingMessage); | ||
baseStore = baseStore.setIn(roomPath, updReceiveRoom); | ||
return _this9.message && _this9.message(roomIdent, _this9.dataFormatter(_immutable2.default.fromJS(sendingMessage))); | ||
return _this9.message && _this9.message(roomIdent, _this9.dataFormatter(sendingMessage)); | ||
}).catch(function (error) { | ||
sendingMessage.isErrorOnSending = true; | ||
sendingMessage = sendingMessage.set('isErrorOnSending', true); | ||
updReceiveRoom = (0, _utils.updateMessageById)(baseStore.getIn(roomPath), msgId, sendingMessage); | ||
baseStore = baseStore.setIn(roomPath, updReceiveRoom); | ||
_this9.message && _this9.message(roomIdent, _this9.dataFormatter(_immutable2.default.fromJS(sendingMessage))); | ||
_this9.message && _this9.message(roomIdent, _this9.dataFormatter(sendingMessage)); | ||
@@ -490,2 +491,20 @@ return _this9.handleRequestErrors(error); | ||
value: function sendContext(roomIdent, contextItemId, contextItemType, contextItemPrice, contextItemCurrency, contextSource, contextDescription, contextMeta, platform, source, device) { | ||
var _this11 = this; | ||
var _getRoomData5 = (0, _utils.getRoomData)(baseStore, roomIdent), | ||
receiveRoom = _getRoomData5.room, | ||
setInEntity = _getRoomData5.setInEntity, | ||
setInIndex = _getRoomData5.setInIndex; | ||
var isTemporaryMessage = true; | ||
var updReceiveRoom = receiveRoom; | ||
var roomPath = [setInEntity, setInIndex]; | ||
var msgId = (0, _uuid2.default)(); | ||
var body = ''; | ||
var sendingMessage = (0, _utils.prepareMessage)(baseStore, msgId, roomIdent, body, platform, source, device, isTemporaryMessage, contextItemId, contextItemType, contextItemPrice, contextItemCurrency, contextSource, contextDescription, contextMeta); | ||
updReceiveRoom = (0, _utils.insertMessage)(updReceiveRoom, sendingMessage); | ||
baseStore = baseStore.setIn(roomPath, updReceiveRoom); | ||
this.message && this.message(roomIdent, this.dataFormatter(sendingMessage)); | ||
return this.oSwindon.call('chat.send_context', [], { | ||
@@ -503,3 +522,18 @@ room_ident: roomIdent, | ||
device: device | ||
}).catch(this.handleRequestErrors); | ||
}).then(function (data) { | ||
sendingMessage = sendingMessage.set('id', data.message_id); | ||
sendingMessage = sendingMessage.set('isTemporaryMessage', false); | ||
updReceiveRoom = (0, _utils.updateMessageById)(baseStore.getIn(roomPath), msgId, sendingMessage); | ||
baseStore = baseStore.setIn(roomPath, updReceiveRoom); | ||
return _this11.message && _this11.message(roomIdent, _this11.dataFormatter(sendingMessage)); | ||
}).catch(function (error) { | ||
sendingMessage = sendingMessage.set('isErrorOnSending', true); | ||
updReceiveRoom = (0, _utils.updateMessageById)(baseStore.getIn(roomPath), msgId, sendingMessage); | ||
baseStore = baseStore.setIn(roomPath, updReceiveRoom); | ||
_this11.message && _this11.message(roomIdent, _this11.dataFormatter(sendingMessage)); | ||
return _this11.handleRequestErrors(error); | ||
}); | ||
} | ||
@@ -509,3 +543,3 @@ }, { | ||
value: function sendChatMeta(roomIdent) { | ||
var _this11 = this; | ||
var _this12 = this; | ||
@@ -515,6 +549,6 @@ return this.oSwindon.call('chat.room', [], { room_ident: roomIdent }).then(function (response) { | ||
var _getRoomData5 = (0, _utils.getRoomData)(baseStore, roomIdent), | ||
newChatRoom = _getRoomData5.room, | ||
setInEntity = _getRoomData5.setInEntity, | ||
setInIndex = _getRoomData5.setInIndex; | ||
var _getRoomData6 = (0, _utils.getRoomData)(baseStore, roomIdent), | ||
newChatRoom = _getRoomData6.room, | ||
setInEntity = _getRoomData6.setInEntity, | ||
setInIndex = _getRoomData6.setInIndex; | ||
@@ -532,3 +566,3 @@ if (!newChatRoom) return roomIdent; | ||
return _this11.dataFormatter(updChat); | ||
return _this12.dataFormatter(updChat); | ||
}).catch(this.handleRequestErrors); | ||
@@ -539,3 +573,3 @@ } | ||
value: function markMsgRead(roomIdent, msgId) { | ||
var _this12 = this; | ||
var _this13 = this; | ||
@@ -552,3 +586,3 @@ return this.oSwindon.call('chat.mark_read', [], { | ||
baseStore = baseStore.setIn([setInEntity, setInIndex, 'last_read_counter'], msgId); | ||
return Promise.resolve(_this12.dataFormatter(_immutable2.default.fromJS({ | ||
return Promise.resolve(_this13.dataFormatter(_immutable2.default.fromJS({ | ||
room_ident: roomIdent, | ||
@@ -578,6 +612,6 @@ message_id: msgId | ||
var _getRoomData6 = (0, _utils.getRoomData)(baseStore, topic), | ||
receiveRoom = _getRoomData6.room, | ||
setInEntity = _getRoomData6.setInEntity, | ||
setInIndex = _getRoomData6.setInIndex; | ||
var _getRoomData7 = (0, _utils.getRoomData)(baseStore, topic), | ||
receiveRoom = _getRoomData7.room, | ||
setInEntity = _getRoomData7.setInEntity, | ||
setInIndex = _getRoomData7.setInIndex; | ||
@@ -606,7 +640,8 @@ var updReceiveRoom = receiveRoom; | ||
var _getRoomData7 = (0, _utils.getRoomData)(baseStore, topic), | ||
setInEntity = _getRoomData7.setInEntity, | ||
setInIndex = _getRoomData7.setInIndex; | ||
var _getRoomData8 = (0, _utils.getRoomData)(baseStore, topic), | ||
setInEntity = _getRoomData8.setInEntity, | ||
setInIndex = _getRoomData8.setInIndex; | ||
var bansImmPath = [setInEntity, setInIndex, 'room_bans']; | ||
var statusImmPath = [setInEntity, setInIndex, 'room_status']; | ||
@@ -616,4 +651,6 @@ !baseStore.getIn(bansImmPath) && (baseStore = baseStore.setIn(bansImmPath, _immutable2.default.List())); | ||
if (data.subject === c.BESIDA_SWINDON_BAN_SUBJECT) { | ||
baseStore = baseStore.setIn(statusImmPath, c.CHAT_STATUS_BANNED); | ||
baseStore = baseStore.setIn(bansImmPath, baseStore.getIn(bansImmPath).push(_immutable2.default.fromJS(_extends({}, data)))); | ||
} else if (data.subject === c.BESIDA_SWINDON_UNBAN_SUBJECT) { | ||
baseStore = baseStore.setIn(statusImmPath, c.CHAT_STATUS_ACTIVE); | ||
baseStore = baseStore.setIn(bansImmPath, baseStore.getIn(bansImmPath).filter(function (user) { | ||
@@ -633,5 +670,5 @@ return user.role === data.role; | ||
var _getRoomData8 = (0, _utils.getRoomData)(baseStore, topic), | ||
setInEntity = _getRoomData8.setInEntity, | ||
setInIndex = _getRoomData8.setInIndex; | ||
var _getRoomData9 = (0, _utils.getRoomData)(baseStore, topic), | ||
setInEntity = _getRoomData9.setInEntity, | ||
setInIndex = _getRoomData9.setInIndex; | ||
@@ -638,0 +675,0 @@ var lastReadImmPath = [setInEntity, setInIndex, 'last_read_messages']; |
@@ -253,3 +253,8 @@ 'use strict'; | ||
}); | ||
return receiveRoom.setIn(['history', msgIndex], _immutable2.default.fromJS(message)); | ||
if (msgIndex === -1) { | ||
return void 0; | ||
} | ||
var msgPath = ['history', msgIndex]; | ||
var msg = receiveRoom.getIn(msgPath); | ||
return receiveRoom.setIn(msgPath, msg.merge(_immutable2.default.fromJS(message))); | ||
} | ||
@@ -270,2 +275,9 @@ | ||
var isTemporaryMessage = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false; | ||
var contextItemId = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null; | ||
var contextItemType = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : null; | ||
var contextItemPrice = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : null; | ||
var contextItemCurrency = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : null; | ||
var contextSource = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : null; | ||
var contextDescription = arguments.length > 13 && arguments[13] !== undefined ? arguments[13] : null; | ||
var contextMeta = arguments.length > 14 && arguments[14] !== undefined ? arguments[14] : null; | ||
@@ -276,3 +288,17 @@ var _getRoomData = getRoomData(baseStore, roomIdent), | ||
var currentUserIdent = getCurrentUserIdent(baseStore); | ||
return { | ||
// this kostil need when we render dialog view and check context type | ||
var cntxType = void 0; | ||
switch (contextItemType) { | ||
case 'product': | ||
cntxType = c.CONTEXT_TYPE_PRODUCT; | ||
break; | ||
case 'order': | ||
cntxType = c.CONTEXT_TYPE_ORDER; | ||
break; | ||
default: | ||
cntxType = null; | ||
break; | ||
} | ||
return _immutable2.default.fromJS({ | ||
id: msgId, | ||
@@ -285,2 +311,9 @@ user_ident: getCurrentUserIdent(baseStore), | ||
isErrorOnSending: false, | ||
context_item_id: contextItemId, | ||
context_item_type: cntxType, | ||
context_item_price: contextItemPrice, | ||
context_item_currency: contextItemCurrency, | ||
context_source: contextSource, | ||
context_description: contextDescription, | ||
context_meta: contextMeta, | ||
isTemporaryMessage: isTemporaryMessage, | ||
@@ -291,3 +324,3 @@ platform: platform, | ||
body: body | ||
}; | ||
}); | ||
} |
{ | ||
"name": "@evo/chat-core", | ||
"version": "0.5.1", | ||
"version": "0.5.4", | ||
"description": "core Besida module with base functional set for chat", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56121
1009