Improved drafts handling
Fixed bug with isIdle in Fx
This commit is contained in:
parent
7be7137fdc
commit
25681537c7
@ -2225,12 +2225,16 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
||||
return
|
||||
}
|
||||
if (newVal && $scope.curDialog.peerID) {
|
||||
DraftsManager.syncDraft($scope.curDialog.peerID)
|
||||
$scope.$broadcast('ui_message_before_send')
|
||||
$timeout(function () {
|
||||
DraftsManager.syncDraft($scope.curDialog.peerID)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
$scope.$on('draft_updated', function (e, draftUpdate) {
|
||||
if (draftUpdate.peerID == $scope.curDialog.peerID) {
|
||||
if (draftUpdate.peerID == $scope.curDialog.peerID &&
|
||||
!draftUpdate.local) {
|
||||
getDraft()
|
||||
}
|
||||
})
|
||||
@ -2373,7 +2377,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
||||
|
||||
function resetDraft (newPeer, prevPeer) {
|
||||
var prevPeerID = prevPeer ? AppPeersManager.getPeerID(prevPeer) : 0
|
||||
if (prevPeerID) {
|
||||
if (newPeer != prevPeer && prevPeerID) {
|
||||
$scope.$broadcast('ui_message_before_send')
|
||||
$timeout(function () {
|
||||
DraftsManager.syncDraft(prevPeerID)
|
||||
|
@ -1005,6 +1005,7 @@ angular.module('izhukov.utils', [])
|
||||
$rootScope.idle = {isIDLE: false, initial: true}
|
||||
|
||||
var toPromise
|
||||
var debouncePromise
|
||||
var started = false
|
||||
|
||||
var hidden = 'hidden'
|
||||
@ -1067,22 +1068,25 @@ angular.module('izhukov.utils', [])
|
||||
}, 10)
|
||||
}
|
||||
|
||||
var debounceTimeout = $rootScope.idle.initial ? 0 : 1000;
|
||||
if (e && !e.fake_initial) {
|
||||
delete $rootScope.idle.initial;
|
||||
}
|
||||
|
||||
$timeout.cancel(debouncePromise)
|
||||
|
||||
if ($rootScope.idle.isIDLE == isIDLE) {
|
||||
return
|
||||
}
|
||||
|
||||
// console.log('IDLE changed', isIDLE)
|
||||
$rootScope.$apply(function () {
|
||||
debouncePromise = $timeout(function () {
|
||||
// console.log(dT(), 'IDLE changed', isIDLE)
|
||||
$rootScope.idle.isIDLE = isIDLE
|
||||
})
|
||||
if (isIDLE && e.type == 'timeout') {
|
||||
$($window).on('mousemove', onEvent)
|
||||
}
|
||||
}, debounceTimeout)
|
||||
|
||||
if (isIDLE && e.type == 'timeout') {
|
||||
$($window).on('mousemove', onEvent)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -4480,7 +4480,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
||||
return
|
||||
}
|
||||
var peerID = AppPeersManager.getPeerID(update.peer)
|
||||
saveDraft(peerID, update.draft, true)
|
||||
saveDraft(peerID, update.draft, {notify: true})
|
||||
})
|
||||
|
||||
return {
|
||||
@ -4526,18 +4526,18 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
||||
return false
|
||||
}
|
||||
|
||||
function saveDraft (peerID, apiDraft, notify) {
|
||||
if (notify) {
|
||||
console.warn(dT(), 'save draft', peerID, apiDraft, notify)
|
||||
}
|
||||
function saveDraft (peerID, apiDraft, options) {
|
||||
options = options || {}
|
||||
var draft = processApiDraft(apiDraft)
|
||||
cachedServerDrafts[peerID] = draft
|
||||
|
||||
if (notify) {
|
||||
if (options.notify) {
|
||||
console.warn(dT(), 'save draft', peerID, apiDraft, options)
|
||||
changeDraft(peerID, draft)
|
||||
$rootScope.$broadcast('draft_updated', {
|
||||
peerID: peerID,
|
||||
draft: draft
|
||||
draft: draft,
|
||||
local: options.sync
|
||||
})
|
||||
}
|
||||
|
||||
@ -4659,7 +4659,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
||||
}
|
||||
MtpApiManager.invokeApi('messages.saveDraft', params).then(function () {
|
||||
draftObj.date = tsNow(true) + ServerTimeManager.serverTimeOffset
|
||||
saveDraft(peerID, draftObj, true)
|
||||
saveDraft(peerID, draftObj, {notify: true, sync: true})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user