Improved drafts sync
This commit is contained in:
parent
37eaf46493
commit
2a4c68827f
@ -42,7 +42,7 @@ angular.module('myApp', [
|
||||
StorageProvider.setPrefix('t_')
|
||||
}
|
||||
|
||||
$routeProvider.when('/', {templateUrl: templateUrl('welcome'), controller: 'AppWelcomeController'})
|
||||
$routeProvider.when('/', {template: '', controller: 'AppWelcomeController'})
|
||||
$routeProvider.when('/login', {templateUrl: templateUrl('login'), controller: 'AppLoginController'})
|
||||
$routeProvider.when('/im', {templateUrl: templateUrl('im'), controller: 'AppIMController', reloadOnSearch: false})
|
||||
$routeProvider.otherwise({redirectTo: '/'})
|
||||
|
@ -2158,7 +2158,11 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
||||
$scope.$on('history_need_more', showMoreHistory)
|
||||
|
||||
$rootScope.$watch('idle.isIDLE', function (newVal) {
|
||||
if (!newVal && $scope.curDialog && $scope.curDialog.peerID && !$scope.historyFilter.mediaType && !$scope.historyState.skipped) {
|
||||
if (!newVal &&
|
||||
$scope.curDialog &&
|
||||
$scope.curDialog.peerID &&
|
||||
!$scope.historyFilter.mediaType &&
|
||||
!$scope.historyState.skipped) {
|
||||
AppMessagesManager.readHistory($scope.curDialog.peerID)
|
||||
}
|
||||
if (!newVal) {
|
||||
@ -2217,6 +2221,9 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
||||
$scope.toggleSlash = toggleSlash
|
||||
|
||||
$rootScope.$watch('idle.isIDLE', function (newVal) {
|
||||
if ($rootScope.idle.initial) {
|
||||
return
|
||||
}
|
||||
if (newVal && $scope.curDialog.peerID) {
|
||||
DraftsManager.syncDraft($scope.curDialog.peerID)
|
||||
}
|
||||
@ -2365,11 +2372,14 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
||||
}
|
||||
|
||||
function resetDraft (newPeer, prevPeer) {
|
||||
if (prevPeer) {
|
||||
var prevPeerID = AppPeersManager.getPeerID(prevPeer)
|
||||
if (prevPeerID) {
|
||||
var prevPeerID = prevPeer ? AppPeersManager.getPeerID(prevPeer) : 0
|
||||
if (prevPeerID) {
|
||||
$scope.$broadcast('ui_message_before_send')
|
||||
$timeout(function () {
|
||||
DraftsManager.syncDraft(prevPeerID)
|
||||
}
|
||||
resetDraft()
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
updateMentions()
|
||||
@ -2565,9 +2575,11 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
||||
return cancelEvent($event)
|
||||
}
|
||||
|
||||
function onMessageChange (newVal) {
|
||||
// console.log('ctrl text changed', newVal)
|
||||
// console.trace('ctrl text changed', newVal)
|
||||
function onMessageChange (newVal, prevVal, a) {
|
||||
// console.log('ctrl text changed', newVal, prevVal);
|
||||
if (newVal === '' && prevVal === '') {
|
||||
return
|
||||
}
|
||||
|
||||
if (newVal && newVal.length) {
|
||||
if (!$scope.historyFilter.mediaType && !$scope.historyState.skipped) {
|
||||
|
@ -1001,7 +1001,8 @@ angular.module('izhukov.utils', [])
|
||||
})
|
||||
|
||||
.service('IdleManager', function ($rootScope, $window, $timeout) {
|
||||
$rootScope.idle = {isIDLE: false}
|
||||
|
||||
$rootScope.idle = {isIDLE: false, initial: true}
|
||||
|
||||
var toPromise
|
||||
var started = false
|
||||
@ -1031,7 +1032,7 @@ angular.module('izhukov.utils', [])
|
||||
$($window).on(visibilityChange + ' blur focus keydown mousedown touchstart', onEvent)
|
||||
|
||||
setTimeout(function () {
|
||||
onEvent({type: 'blur'})
|
||||
onEvent({type: 'blur', fake_initial: true})
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
@ -1066,6 +1067,10 @@ angular.module('izhukov.utils', [])
|
||||
}, 10)
|
||||
}
|
||||
|
||||
if (e && !e.fake_initial) {
|
||||
delete $rootScope.idle.initial;
|
||||
}
|
||||
|
||||
if ($rootScope.idle.isIDLE == isIDLE) {
|
||||
return
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
{
|
||||
"follow_symlinks": true,
|
||||
"path": ".",
|
||||
"folder_exclude_patterns": ["*dist*", "node_modules", "releases", ".tx", "css"],
|
||||
"folder_exclude_patterns": ["*dist*", ".publish", "node_modules", "releases", ".tx", "css"],
|
||||
"file_exclude_patterns": ["*.zip", "templates.js"]
|
||||
}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user