diff --git a/css/app.css b/css/app.css index 5f9ea882..15570037 100644 --- a/css/app.css +++ b/css/app.css @@ -897,7 +897,8 @@ a.im_dialog:hover .im_dialog_date { }*/ .im_message_unread_split { - background: #E9EBED; + background: #f4f4f4; + color: #777; text-align: center; padding: 4px 10px; margin: 10px 0; diff --git a/js/controllers.js b/js/controllers.js index dd7c8a49..9edee50a 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -598,7 +598,9 @@ angular.module('myApp.controllers', []) $scope.history.push(AppMessagesManager.wrapForHistory(addedMessage.messageID)); $scope.typing = {}; $scope.$broadcast('ui_history_append', {my: addedMessage.my}); - $scope.historyUnread = {}; + if (addedMessage.my) { + $scope.historyUnread = {}; + } offset++; diff --git a/js/directives.js b/js/directives.js index e49ad249..e23d52e3 100644 --- a/js/directives.js +++ b/js/directives.js @@ -438,6 +438,9 @@ angular.module('myApp.directives', ['myApp.filters']) $('body').on('dragenter dragleave dragover drop', onDragDropEvent); $(document).on('paste', onPasteEvent); + if (richTextarea) { + $(richTextarea).on('DOMNodeInserted', onPastedImageEvent); + } scope.$on('ui_peer_change', focusField); scope.$on('ui_history_focus', focusField); @@ -450,6 +453,9 @@ angular.module('myApp.directives', ['myApp.filters']) scope.$on('$destroy', function cleanup() { $('body').off('dragenter dragleave dragover drop', onDragDropEvent); $(document).off('paste', onPasteEvent); + if (richTextarea) { + $(richTextarea).off('DOMNodeInserted', onPastedImageEvent); + } }); focusField(); @@ -460,6 +466,31 @@ angular.module('myApp.directives', ['myApp.filters']) }); } + function onPastedImageEvent (e) { + var element = e && e.target; + var src; + if (element && (src = element.src) && src.indexOf('data') === 0) { + element.parentNode.removeChild(element); + src = src.substr(5).split(';'); + var contentType = src[0]; + var base64 = atob(src[1].split(',')[1]); + var array = new Uint8Array(base64.length); + + for (var i = 0; i < base64.length; i++) { + array[i] = base64.charCodeAt(i); + } + + var blob = new Blob([array], {type: contentType}); + + if (safeConfirm('Are you sure to send file(s) from clipboard?')) { + scope.$apply(function () { + scope.draftMessage.files = [blob]; + scope.draftMessage.isMedia = true; + }); + } + } + }; + function onPasteEvent (e) { var cData = (e.originalEvent || e).clipboardData, items = cData && cData.items || [], diff --git a/js/services.js b/js/services.js index 5a84dbf1..224a9591 100644 --- a/js/services.js +++ b/js/services.js @@ -805,7 +805,7 @@ angular.module('myApp.services', []) var unreadLimit = false; if (!limit && !maxID) { var foundDialog = getDialogByPeerID(peerID); - if (foundDialog && foundDialog[0] && foundDialog[0].unread_count > 0) { + if (foundDialog && foundDialog[0] && foundDialog[0].unread_count > 1) { unreadLimit = foundDialog[0].unread_count; limit = Math.max(20, unreadLimit + 2); }