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