|
|
@ -502,6 +502,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
channelActions: false, |
|
|
|
channelActions: false, |
|
|
|
canReply: false, |
|
|
|
canReply: false, |
|
|
|
canDelete: false, |
|
|
|
canDelete: false, |
|
|
|
|
|
|
|
canEdit: false, |
|
|
|
actions: function () { |
|
|
|
actions: function () { |
|
|
|
return $scope.historyState.selectActions ? 'selected' : ($scope.historyState.botActions ? 'bot' : ($scope.historyState.channelActions ? 'channel' : false)) |
|
|
|
return $scope.historyState.selectActions ? 'selected' : ($scope.historyState.botActions ? 'bot' : ($scope.historyState.channelActions ? 'channel' : false)) |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1130,6 +1131,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
$scope.selectedDelete = selectedDelete |
|
|
|
$scope.selectedDelete = selectedDelete |
|
|
|
$scope.selectedForward = selectedForward |
|
|
|
$scope.selectedForward = selectedForward |
|
|
|
$scope.selectedReply = selectedReply |
|
|
|
$scope.selectedReply = selectedReply |
|
|
|
|
|
|
|
$scope.selectedEdit = selectedEdit |
|
|
|
$scope.selectedCancel = selectedCancel |
|
|
|
$scope.selectedCancel = selectedCancel |
|
|
|
$scope.selectedFlush = selectedFlush |
|
|
|
$scope.selectedFlush = selectedFlush |
|
|
|
$scope.selectInlineBot = selectInlineBot |
|
|
|
$scope.selectInlineBot = selectInlineBot |
|
|
@ -1610,8 +1612,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
} |
|
|
|
} |
|
|
|
if (target.className && |
|
|
|
if (target.className && |
|
|
|
target.className.indexOf('im_message_date') != -1) { |
|
|
|
target.className.indexOf('im_message_date') != -1) { |
|
|
|
if (AppPeersManager.isChannel(peerID) && |
|
|
|
if (AppPeersManager.isBroadcast(peerID)) { |
|
|
|
!AppPeersManager.isMegagroup(peerID)) { |
|
|
|
|
|
|
|
quickForward(messageID) |
|
|
|
quickForward(messageID) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
selectedReply(messageID) |
|
|
|
selectedReply(messageID) |
|
|
@ -1630,6 +1631,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (Config.Mobile) { |
|
|
|
if (Config.Mobile) { |
|
|
|
|
|
|
|
$scope.historyState.canEdit = AppMessagesManager.canEditMessage(messageID) |
|
|
|
|
|
|
|
|
|
|
|
$modal.open({ |
|
|
|
$modal.open({ |
|
|
|
templateUrl: templateUrl('message_actions_modal'), |
|
|
|
templateUrl: templateUrl('message_actions_modal'), |
|
|
|
windowClass: 'message_actions_modal_window', |
|
|
|
windowClass: 'message_actions_modal_window', |
|
|
@ -1640,6 +1643,10 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
selectedReply(messageID) |
|
|
|
selectedReply(messageID) |
|
|
|
break |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'edit': |
|
|
|
|
|
|
|
selectedEdit(messageID) |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
case 'delete': |
|
|
|
case 'delete': |
|
|
|
selectedDelete(messageID) |
|
|
|
selectedDelete(messageID) |
|
|
|
break |
|
|
|
break |
|
|
@ -1704,6 +1711,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
$scope.$broadcast('ui_panel_update') |
|
|
|
$scope.$broadcast('ui_panel_update') |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($scope.selectedCount == 1) { |
|
|
|
|
|
|
|
angular.forEach($scope.selectedMsgs, function (t, messageID) { |
|
|
|
|
|
|
|
$scope.historyState.canEdit = AppMessagesManager.canEditMessage(messageID) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
$scope.$broadcast('messages_select') |
|
|
|
$scope.$broadcast('messages_select') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1813,6 +1825,18 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function selectedEdit (selectedMessageID) { |
|
|
|
|
|
|
|
if (!selectedMessageID && $scope.selectedCount == 1) { |
|
|
|
|
|
|
|
angular.forEach($scope.selectedMsgs, function (t, messageID) { |
|
|
|
|
|
|
|
selectedMessageID = messageID |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (selectedMessageID) { |
|
|
|
|
|
|
|
selectedCancel() |
|
|
|
|
|
|
|
$scope.$broadcast('edit_selected', selectedMessageID) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function toggleEdit () { |
|
|
|
function toggleEdit () { |
|
|
|
if ($scope.historyState.selectActions) { |
|
|
|
if ($scope.historyState.selectActions) { |
|
|
|
selectedCancel() |
|
|
|
selectedCancel() |
|
|
@ -2202,13 +2226,18 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
$scope.$on('reply_selected', function (e, messageID) { |
|
|
|
$scope.$on('reply_selected', function (e, messageID) { |
|
|
|
replySelect(messageID, true) |
|
|
|
replySelect(messageID, true) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
$scope.$on('edit_selected', function (e, messageID) { |
|
|
|
|
|
|
|
setEditDraft(messageID, true) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
$scope.$on('ui_typing', onTyping) |
|
|
|
$scope.$on('ui_typing', onTyping) |
|
|
|
|
|
|
|
|
|
|
|
$scope.draftMessage = { |
|
|
|
$scope.draftMessage = { |
|
|
|
text: '', |
|
|
|
text: '', |
|
|
|
send: sendMessage, |
|
|
|
send: submitMessage, |
|
|
|
replyClear: replyClear, |
|
|
|
replyClear: replyClear, |
|
|
|
fwdsClear: fwdsClear |
|
|
|
fwdsClear: fwdsClear, |
|
|
|
|
|
|
|
type: 'new' |
|
|
|
} |
|
|
|
} |
|
|
|
$scope.mentions = {} |
|
|
|
$scope.mentions = {} |
|
|
|
$scope.commands = {} |
|
|
|
$scope.commands = {} |
|
|
@ -2232,6 +2261,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
|
|
|
|
|
|
|
|
$scope.$on('inline_bots_popular', updateMentions) |
|
|
|
$scope.$on('inline_bots_popular', updateMentions) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.$on('last_message_edit', setEditLastMessage) |
|
|
|
|
|
|
|
|
|
|
|
$scope.replyKeyboardToggle = replyKeyboardToggle |
|
|
|
$scope.replyKeyboardToggle = replyKeyboardToggle |
|
|
|
$scope.toggleSlash = toggleSlash |
|
|
|
$scope.toggleSlash = toggleSlash |
|
|
|
|
|
|
|
|
|
|
@ -2257,11 +2288,23 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
|
|
|
|
|
|
|
|
var replyToMarkup = false |
|
|
|
var replyToMarkup = false |
|
|
|
var forceDraft = false |
|
|
|
var forceDraft = false |
|
|
|
|
|
|
|
var editMessageID = false |
|
|
|
|
|
|
|
|
|
|
|
function sendMessage (e) { |
|
|
|
function submitMessage (e) { |
|
|
|
$scope.$broadcast('ui_message_before_send') |
|
|
|
$scope.$broadcast('ui_message_before_send') |
|
|
|
|
|
|
|
|
|
|
|
$timeout(function () { |
|
|
|
$timeout(function () { |
|
|
|
|
|
|
|
if (editMessageID) { |
|
|
|
|
|
|
|
editMessage() |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
sendMessage() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return cancelEvent(e) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sendMessage() { |
|
|
|
var text = $scope.draftMessage.text |
|
|
|
var text = $scope.draftMessage.text |
|
|
|
|
|
|
|
|
|
|
|
if (angular.isString(text) && text.length > 0) { |
|
|
|
if (angular.isString(text) && text.length > 0) { |
|
|
@ -2286,9 +2329,17 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
|
|
|
|
|
|
|
|
resetDraft() |
|
|
|
resetDraft() |
|
|
|
$scope.$broadcast('ui_message_send') |
|
|
|
$scope.$broadcast('ui_message_send') |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return cancelEvent(e) |
|
|
|
function editMessage() { |
|
|
|
|
|
|
|
var text = $scope.draftMessage.text |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AppMessagesManager.editMessage(editMessageID, text).then(function () { |
|
|
|
|
|
|
|
editMessageID = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resetDraft() |
|
|
|
|
|
|
|
$scope.$broadcast('ui_message_send') |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function updateMentions () { |
|
|
|
function updateMentions () { |
|
|
@ -2402,6 +2453,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
editMessageID = false |
|
|
|
|
|
|
|
|
|
|
|
updateMentions() |
|
|
|
updateMentions() |
|
|
|
updateCommands() |
|
|
|
updateCommands() |
|
|
|
replyClear() |
|
|
|
replyClear() |
|
|
@ -2413,7 +2466,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
// console.log(dT(), 'reset draft', $scope.curDialog.peer, forceDraft)
|
|
|
|
// console.log(dT(), 'reset draft', $scope.curDialog.peer, forceDraft)
|
|
|
|
if (forceDraft) { |
|
|
|
if (forceDraft) { |
|
|
|
if (forceDraft == $scope.curDialog.peer) { |
|
|
|
if (forceDraft == $scope.curDialog.peer) { |
|
|
|
$scope.draftMessage.isBroadcast = AppPeersManager.isChannel($scope.curDialog.peerID) && !AppPeersManager.isMegagroup($scope.curDialog.peerID) |
|
|
|
$scope.draftMessage.isBroadcast = AppPeersManager.isBroadcast($scope.curDialog.peerID) |
|
|
|
$scope.$broadcast('ui_peer_draft') |
|
|
|
$scope.$broadcast('ui_peer_draft') |
|
|
|
return |
|
|
|
return |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -2427,9 +2480,25 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
|
|
|
|
|
|
|
|
function getDraft () { |
|
|
|
function getDraft () { |
|
|
|
if ($scope.curDialog.peerID) { |
|
|
|
if ($scope.curDialog.peerID) { |
|
|
|
DraftsManager.getDraft($scope.curDialog.peerID).then(function (draftData) { |
|
|
|
var draftDataPromise |
|
|
|
|
|
|
|
if (editMessageID) { |
|
|
|
|
|
|
|
draftDataPromise = AppMessagesManager.getMessageEditData(editMessageID).then(function (draftData) { |
|
|
|
|
|
|
|
draftData.replyToMsgID = editMessageID |
|
|
|
|
|
|
|
return draftData |
|
|
|
|
|
|
|
}, function (error) { |
|
|
|
|
|
|
|
console.warn(error) |
|
|
|
|
|
|
|
editMessageID = false |
|
|
|
|
|
|
|
getDraft() |
|
|
|
|
|
|
|
return $q.reject() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
draftDataPromise = DraftsManager.getDraft($scope.curDialog.peerID) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
draftDataPromise.then(function (draftData) { |
|
|
|
|
|
|
|
console.warn('draft', editMessageID, draftData) |
|
|
|
|
|
|
|
$scope.draftMessage.type = editMessageID ? 'edit' : 'new' |
|
|
|
$scope.draftMessage.text = draftData ? draftData.text : '' |
|
|
|
$scope.draftMessage.text = draftData ? draftData.text : '' |
|
|
|
$scope.draftMessage.isBroadcast = AppPeersManager.isChannel($scope.curDialog.peerID) && !AppPeersManager.isMegagroup($scope.curDialog.peerID) |
|
|
|
$scope.draftMessage.isBroadcast = AppPeersManager.isBroadcast($scope.curDialog.peerID) |
|
|
|
if (draftData.replyToMsgID) { |
|
|
|
if (draftData.replyToMsgID) { |
|
|
|
var replyToMsgID = draftData.replyToMsgID |
|
|
|
var replyToMsgID = draftData.replyToMsgID |
|
|
|
replySelect(replyToMsgID) |
|
|
|
replySelect(replyToMsgID) |
|
|
@ -2493,11 +2562,15 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function replySelect (messageID, byUser) { |
|
|
|
function replySelect (messageID, byUser) { |
|
|
|
|
|
|
|
if (editMessageID && byUser) { |
|
|
|
|
|
|
|
replyClear() |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
$scope.draftMessage.replyToMsgID = messageID |
|
|
|
$scope.draftMessage.replyToMsgID = messageID |
|
|
|
$scope.$broadcast('ui_peer_reply') |
|
|
|
$scope.$broadcast('ui_peer_reply') |
|
|
|
replyToMarkup = false |
|
|
|
replyToMarkup = false |
|
|
|
|
|
|
|
|
|
|
|
if (byUser) { |
|
|
|
if (byUser && !editMessageID) { |
|
|
|
DraftsManager.changeDraft($scope.curDialog.peerID, { |
|
|
|
DraftsManager.changeDraft($scope.curDialog.peerID, { |
|
|
|
text: $scope.draftMessage.text, |
|
|
|
text: $scope.draftMessage.text, |
|
|
|
replyToMsgID: messageID |
|
|
|
replyToMsgID: messageID |
|
|
@ -2505,7 +2578,33 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setEditDraft(messageID) { |
|
|
|
|
|
|
|
editMessageID = messageID |
|
|
|
|
|
|
|
getDraft() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setEditLastMessage() { |
|
|
|
|
|
|
|
if (editMessageID || |
|
|
|
|
|
|
|
!$scope.curDialog.peerID) { |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
AppMessagesManager.getHistory($scope.curDialog.peerID).then(function (historyResult) { |
|
|
|
|
|
|
|
for (var i = 0, messageID; i < historyResult.history.length; i++) { |
|
|
|
|
|
|
|
messageID = historyResult.history[i] |
|
|
|
|
|
|
|
if (AppMessagesManager.canEditMessage(messageID)) { |
|
|
|
|
|
|
|
setEditDraft(messageID) |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function replyClear (byUser) { |
|
|
|
function replyClear (byUser) { |
|
|
|
|
|
|
|
if (editMessageID) { |
|
|
|
|
|
|
|
editMessageID = false |
|
|
|
|
|
|
|
getDraft() |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
var mid = $scope.draftMessage.replyToMsgID |
|
|
|
var mid = $scope.draftMessage.replyToMsgID |
|
|
|
if (mid && |
|
|
|
if (mid && |
|
|
|
$scope.historyState.replyKeyboard && |
|
|
|
$scope.historyState.replyKeyboard && |
|
|
@ -2608,6 +2707,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if ($scope.curDialog.peerID) { |
|
|
|
if ($scope.curDialog.peerID) { |
|
|
|
|
|
|
|
if (!editMessageID) { |
|
|
|
var replyToMsgID = $scope.draftMessage.replyToMsgID |
|
|
|
var replyToMsgID = $scope.draftMessage.replyToMsgID |
|
|
|
if (replyToMsgID && |
|
|
|
if (replyToMsgID && |
|
|
|
$scope.historyState.replyKeyboard && |
|
|
|
$scope.historyState.replyKeyboard && |
|
|
@ -2618,6 +2718,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
text: newVal, |
|
|
|
text: newVal, |
|
|
|
replyToMsgID: replyToMsgID |
|
|
|
replyToMsgID: replyToMsgID |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
checkInlinePattern(newVal) |
|
|
|
checkInlinePattern(newVal) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2685,8 +2786,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function onTyping () { |
|
|
|
function onTyping () { |
|
|
|
if (AppPeersManager.isChannel($scope.curDialog.peerID) && |
|
|
|
if (AppPeersManager.isBroadcast($scope.curDialog.peerID)) { |
|
|
|
!AppPeersManager.isMegagroup($scope.curDialog.peerID)) { |
|
|
|
|
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
MtpApiManager.invokeApi('messages.setTyping', { |
|
|
|
MtpApiManager.invokeApi('messages.setTyping', { |
|
|
|