@ -233,6 +233,7 @@ angular.module('myApp.controllers', [])
$scope . search = { } ;
$scope . search = { } ;
$scope . historyFilter = { mediaType : false } ;
$scope . historyFilter = { mediaType : false } ;
$scope . historyPeer = { } ;
$scope . historyPeer = { } ;
$scope . historyState = { selectActions : false , typing : [ ] } ;
$scope . openSettings = function ( ) {
$scope . openSettings = function ( ) {
$modal . open ( {
$modal . open ( {
@ -637,9 +638,8 @@ angular.module('myApp.controllers', [])
$scope . skippedHistory = false ;
$scope . skippedHistory = false ;
$scope . selectedMsgs = { } ;
$scope . selectedMsgs = { } ;
$scope . selectedCount = 0 ;
$scope . selectedCount = 0 ;
$scope . selectActions = false ;
$scope . historyState . selectActions = false ;
$scope . missedCount = 0 ;
$scope . missedCount = 0 ;
$scope . typing = { } ;
$scope . state = { } ;
$scope . state = { } ;
$scope . toggleMessage = toggleMessage ;
$scope . toggleMessage = toggleMessage ;
@ -721,7 +721,7 @@ angular.module('myApp.controllers', [])
} ) ;
} ) ;
if ( preload ) {
if ( preload ) {
$scope . typing = { } ;
$scope . historyState . typing . splice ( ) ;
$scope . $broadcast ( 'ui_peer_change' ) ;
$scope . $broadcast ( 'ui_peer_change' ) ;
$scope . $broadcast ( 'ui_history_change' ) ;
$scope . $broadcast ( 'ui_history_change' ) ;
safeReplaceObject ( $scope . state , { loaded : true } ) ;
safeReplaceObject ( $scope . state , { loaded : true } ) ;
@ -900,7 +900,7 @@ angular.module('myApp.controllers', [])
$scope . $broadcast ( 'ui_selection_clear' ) ;
$scope . $broadcast ( 'ui_selection_clear' ) ;
}
}
if ( ! $scope . selectActions && ! $ ( target ) . hasClass ( 'icon-select-tick' ) && ! $ ( target ) . hasClass ( 'im_content_message_select_area' ) ) {
if ( ! $scope . historyState . selectActions && ! $ ( target ) . hasClass ( 'icon-select-tick' ) && ! $ ( target ) . hasClass ( 'im_content_message_select_area' ) ) {
return false ;
return false ;
}
}
@ -909,7 +909,7 @@ angular.module('myApp.controllers', [])
delete $scope . selectedMsgs [ messageID ] ;
delete $scope . selectedMsgs [ messageID ] ;
$scope . selectedCount -- ;
$scope . selectedCount -- ;
if ( ! $scope . selectedCount ) {
if ( ! $scope . selectedCount ) {
$scope . selectActions = false ;
$scope . historyState . selectActions = false ;
$scope . $broadcast ( 'ui_panel_update' ) ;
$scope . $broadcast ( 'ui_panel_update' ) ;
}
}
} else {
} else {
@ -940,8 +940,8 @@ angular.module('myApp.controllers', [])
$scope . selectedMsgs [ messageID ] = true ;
$scope . selectedMsgs [ messageID ] = true ;
$scope . selectedCount ++ ;
$scope . selectedCount ++ ;
if ( ! $scope . selectActions ) {
if ( ! $scope . historyState . selectActions ) {
$scope . selectActions = true ;
$scope . historyState . selectActions = true ;
$scope . $broadcast ( 'ui_panel_update' ) ;
$scope . $broadcast ( 'ui_panel_update' ) ;
}
}
}
}
@ -950,7 +950,7 @@ angular.module('myApp.controllers', [])
function selectedCancel ( noBroadcast ) {
function selectedCancel ( noBroadcast ) {
$scope . selectedMsgs = { } ;
$scope . selectedMsgs = { } ;
$scope . selectedCount = 0 ;
$scope . selectedCount = 0 ;
$scope . selectActions = false ;
$scope . historyState . selectActions = false ;
lastSelectID = false ;
lastSelectID = false ;
if ( ! noBroadcast ) {
if ( ! noBroadcast ) {
$scope . $broadcast ( 'ui_panel_update' ) ;
$scope . $broadcast ( 'ui_panel_update' ) ;
@ -997,10 +997,10 @@ angular.module('myApp.controllers', [])
}
}
function toggleEdit ( ) {
function toggleEdit ( ) {
if ( $scope . selectActions ) {
if ( $scope . historyState . selectActions ) {
selectedCancel ( ) ;
selectedCancel ( ) ;
} else {
} else {
$scope . selectActions = true ;
$scope . historyState . selectActions = true ;
$scope . $broadcast ( 'ui_panel_update' ) ;
$scope . $broadcast ( 'ui_panel_update' ) ;
}
}
}
}
@ -1023,11 +1023,9 @@ angular.module('myApp.controllers', [])
}
}
}
}
var typingTimeouts = { } ;
$scope . $on ( 'history_update' , angular . noop ) ;
$scope . $on ( 'history_update' , angular . noop ) ;
var typingTimeouts = { } ;
$scope . $on ( 'history_append' , function ( e , addedMessage ) {
$scope . $on ( 'history_append' , function ( e , addedMessage ) {
if ( addedMessage . peerID == $scope . curDialog . peerID ) {
if ( addedMessage . peerID == $scope . curDialog . peerID ) {
if ( $scope . historyFilter . mediaType || $scope . skippedHistory ) {
if ( $scope . historyFilter . mediaType || $scope . skippedHistory ) {
@ -1042,7 +1040,7 @@ angular.module('myApp.controllers', [])
// console.trace();
// console.trace();
$scope . history . push ( AppMessagesManager . wrapForHistory ( addedMessage . messageID ) ) ;
$scope . history . push ( AppMessagesManager . wrapForHistory ( addedMessage . messageID ) ) ;
AppMessagesManager . regroupWrappedHistory ( $scope . history , - 3 ) ;
AppMessagesManager . regroupWrappedHistory ( $scope . history , - 3 ) ;
$scope . typing = { } ;
$scope . historyState . typing . splice ( ) ;
$scope . $broadcast ( 'ui_history_append_new' , { my : addedMessage . my } ) ;
$scope . $broadcast ( 'ui_history_append_new' , { my : addedMessage . my } ) ;
if ( addedMessage . my ) {
if ( addedMessage . my ) {
delete $scope . historyUnreadAfter ;
delete $scope . historyUnreadAfter ;
@ -1084,28 +1082,24 @@ angular.module('myApp.controllers', [])
} ) ;
} ) ;
$scope . $on ( 'apiUpdate' , function ( e , update ) {
$scope . $on ( 'apiUpdate' , function ( e , update ) {
// console.log('on apiUpdate inline', update);
switch ( update . _ ) {
switch ( update . _ ) {
case 'updateUserTyping' :
case 'updateUserTyping' :
if ( update . user _id == $scope . curDialog . peerID && AppUsersManager . hasUser ( update . user _id ) ) {
$scope . typing = { user : AppUsersManager . getUser ( update . user _id ) } ;
$timeout . cancel ( typingTimeouts [ update . user _id ] ) ;
typingTimeouts [ update . user _id ] = $timeout ( function ( ) {
$scope . typing = { } ;
} , 6000 ) ;
}
break ;
case 'updateChatUserTyping' :
case 'updateChatUserTyping' :
if ( - update . chat _id == $scope . curDialog . peerID && AppUsersManager . hasUser ( update . user _id ) ) {
if ( AppUsersManager . hasUser ( update . user _id ) &&
$scope . typing = { user : AppUsersManager . getUser ( update . user _id ) } ;
$scope . curDialog . peerID == ( update . _ == 'updateUserTyping'
? update . user _id
: - update . chat _id
) ) {
if ( $scope . historyState . typing . indexOf ( update . user _id ) == - 1 ) {
$scope . historyState . typing . push ( update . user _id ) ;
}
$timeout . cancel ( typingTimeouts [ update . user _id ] ) ;
$timeout . cancel ( typingTimeouts [ update . user _id ] ) ;
typingTimeouts [ update . user _id ] = $timeout ( function ( ) {
typingTimeouts [ update . user _id ] = $timeout ( function ( ) {
$scope . typing = { } ;
var pos = $scope . historyState . typing . indexOf ( update . user _id ) ;
if ( pos !== - 1 ) {
$scope . historyState . typing . splice ( pos , 1 ) ;
}
} , 6000 ) ;
} , 6000 ) ;
}
}
break ;
break ;