diff --git a/app/css/app.css b/app/css/app.css index 05bddefd..78fd5afc 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -693,17 +693,23 @@ a.im_dialog:hover .im_dialog_date { font-size: 13px; margin-left: 5px; } -.im_history_panel_info_link { +.im_history_panel_info_link, +.im_history_panel_edit_link { color: #3a6d99; font-size: 13px; font-weight: normal; padding-top: 5px; line-height: 1; } -.im_history_panel_info_link:hover { +.im_history_panel_info_link:hover, +.im_history_panel_edit_link:hover { text-decoration: underline; } +.im_history_panel_edit_link { + margin-right: 10px; +} + .im_history_wrap { overflow: hidden; @@ -1340,9 +1346,14 @@ img.img_fullsize { } .user_modal_window .modal-dialog { - padding-top: 150px; max-width: 506px; } +@media (min-height: 768px) { + .user_modal_window .modal-dialog { + padding-top: 150px; + } +} + .user_modal_wrap .modal-body { padding: 23px 25px 30px; } diff --git a/app/js/controllers.js b/app/js/controllers.js index 95a3cf60..b2fdec44 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -209,7 +209,7 @@ angular.module('myApp.controllers', []) $scope.$on('dialog_unread', function (e, dialog) { angular.forEach($scope.dialogs, function(curDialog) { if (curDialog.peerID == dialog.peerID) { - curDialog.unreadCount = dialog.unread_count; + curDialog.unreadCount = dialog.count; } }); }); @@ -312,7 +312,9 @@ angular.module('myApp.controllers', []) $scope.selectedCount = 0; $scope.selectActions = false; $scope.toggleMessage = toggleMessage; + $scope.selectedDelete = selectedDelete; $scope.selectedCancel = selectedCancel; + $scope.toggleEdit = toggleEdit; $scope.typing = {}; $scope.state = {}; @@ -453,6 +455,27 @@ angular.module('myApp.controllers', []) $scope.$broadcast('ui_panel_update'); } + function selectedDelete () { + if ($scope.selectedCount > 0) { + var selectedMessageIDs = []; + angular.forEach($scope.selectedMsgs, function (t, messageID) { + selectedMessageIDs.push(messageID); + }); + AppMessagesManager.deleteMessages(selectedMessageIDs).then(function () { + selectedCancel(); + }); + } + } + + function toggleEdit () { + if ($scope.selectActions) { + selectedCancel(); + } else { + $scope.selectActions = true; + $scope.$broadcast('ui_panel_update'); + } + } + var typingTimeouts = {}; @@ -476,6 +499,19 @@ angular.module('myApp.controllers', []) } }); + $scope.$on('history_delete', function (e, historyUpdate) { + if (historyUpdate.peerID == $scope.curDialog.peerID) { + var newHistory = []; + + for (var i = 0; i < $scope.history.length; i++) { + if (!historyUpdate.msgs[$scope.history[i].id]) { + newHistory.push($scope.history[i]); + } + }; + $scope.history = newHistory; + } + }) + $scope.$on('dialog_flush', function (e, dialog) { if (dialog.peerID == $scope.curDialog.peerID) { $scope.history = []; diff --git a/app/js/directives.js b/app/js/directives.js index c29c8ce9..03185746 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -204,14 +204,20 @@ angular.module('myApp.directives', ['myApp.filters']) }); scope.$on('ui_panel_update', function () { - element.addClass('im_panel_to_top'); + var h = $(historyWrap).height(); + $(panelWrap).addClass('im_panel_to_top'); onContentLoaded(function () { - element.removeClass('im_panel_to_top'); + $(panelWrap).removeClass('im_panel_to_top'); updateSizes(true); + var newH = $(historyWrap).height(); + if (atBottom) { scrollableWrap.scrollTop = scrollableWrap.scrollHeight; updateScroller(); + } else { + scrollableWrap.scrollTop -= newH - h; + updateScroller(); } }); }); diff --git a/app/js/services.js b/app/js/services.js index 114c73df..61ed3971 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -746,6 +746,22 @@ angular.module('myApp.services', []) return deferred.promise; } + function deleteMessages (messageIDs) { + return MtpApiManager.invokeApi('messages.deleteMessages', { + id: messageIDs + }).then(function (deletedMessageIDs) { + + ApiUpdatesManager.saveUpdate({ + _: 'updateDeleteMessages', + messages: deletedMessageIDs + }); + + return deletedMessageIDs; + }); + + + } + function processAffectedHistory (inputPeer, affectedHistory, method) { if (!ApiUpdatesManager.saveSeq(affectedHistory.seq)) { return false; @@ -1419,7 +1435,7 @@ angular.module('myApp.services', []) message = messagesStorage[messageID]; if (message) { peerID = getMessagePeer(message); - history = historiesUpdated[peer] || (historiesUpdated[peer] = {count: 0, unread: 0, msgs: {}}); + history = historiesUpdated[peerID] || (historiesUpdated[peerID] = {count: 0, unread: 0, msgs: {}}); if (!message.out && message.unread) { history.unread++; @@ -1460,6 +1476,7 @@ angular.module('myApp.services', []) } } historyStorage.history = newHistory; + $rootScope.$broadcast('history_delete', {peerID: peerID, msgs: updatedData.msgs}); } }); break; @@ -1471,6 +1488,7 @@ angular.module('myApp.services', []) getHistory: getHistory, readHistory: readHistory, flushHistory: flushHistory, + deleteMessages: deleteMessages, saveMessages: saveMessages, sendText: sendText, sendFile: sendFile, diff --git a/app/partials/im.html b/app/partials/im.html index 2b381a7c..7067ae5c 100644 --- a/app/partials/im.html +++ b/app/partials/im.html @@ -31,9 +31,10 @@
-
+
Info -

+ Edit +

-
+
Info -

+ Edit +

{{historyPeer.data | userStatus}}