diff --git a/app/js/app.js b/app/js/app.js index d22b557c..8de3184e 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -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: '/'}) diff --git a/app/js/controllers.js b/app/js/controllers.js index b97130e7..a3a68ec9 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -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) { diff --git a/app/js/lib/ng_utils.js b/app/js/lib/ng_utils.js index da91f2b1..7034d29f 100644 --- a/app/js/lib/ng_utils.js +++ b/app/js/lib/ng_utils.js @@ -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 } diff --git a/webogram.sublime-project b/webogram.sublime-project index 96c52876..f9f67635 100644 --- a/webogram.sublime-project +++ b/webogram.sublime-project @@ -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"] } ]