Browse Source

Improved drafts sync

master
Igor Zhukov 8 years ago
parent
commit
2a4c68827f
  1. 2
      app/js/app.js
  2. 28
      app/js/controllers.js
  3. 9
      app/js/lib/ng_utils.js
  4. 2
      webogram.sublime-project

2
app/js/app.js

@ -42,7 +42,7 @@ angular.module('myApp', [ @@ -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: '/'})

28
app/js/controllers.js

@ -2158,7 +2158,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -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']) @@ -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']) @@ -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']) @@ -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) {

9
app/js/lib/ng_utils.js

@ -1001,7 +1001,8 @@ angular.module('izhukov.utils', []) @@ -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', []) @@ -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', []) @@ -1066,6 +1067,10 @@ angular.module('izhukov.utils', [])
}, 10)
}
if (e && !e.fake_initial) {
delete $rootScope.idle.initial;
}
if ($rootScope.idle.isIDLE == isIDLE) {
return
}

2
webogram.sublime-project vendored

@ -4,7 +4,7 @@ @@ -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…
Cancel
Save