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
|
return
|
||||||
}
|
}
|
||||||
if (newVal && $scope.curDialog.peerID) {
|
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) {
|
$scope.$on('draft_updated', function (e, draftUpdate) {
|
||||||
if (draftUpdate.peerID == $scope.curDialog.peerID) {
|
if (draftUpdate.peerID == $scope.curDialog.peerID &&
|
||||||
|
!draftUpdate.local) {
|
||||||
getDraft()
|
getDraft()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -2373,7 +2377,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
|
|
||||||
function resetDraft (newPeer, prevPeer) {
|
function resetDraft (newPeer, prevPeer) {
|
||||||
var prevPeerID = prevPeer ? AppPeersManager.getPeerID(prevPeer) : 0
|
var prevPeerID = prevPeer ? AppPeersManager.getPeerID(prevPeer) : 0
|
||||||
if (prevPeerID) {
|
if (newPeer != prevPeer && prevPeerID) {
|
||||||
$scope.$broadcast('ui_message_before_send')
|
$scope.$broadcast('ui_message_before_send')
|
||||||
$timeout(function () {
|
$timeout(function () {
|
||||||
DraftsManager.syncDraft(prevPeerID)
|
DraftsManager.syncDraft(prevPeerID)
|
||||||
|
@ -1005,6 +1005,7 @@ angular.module('izhukov.utils', [])
|
|||||||
$rootScope.idle = {isIDLE: false, initial: true}
|
$rootScope.idle = {isIDLE: false, initial: true}
|
||||||
|
|
||||||
var toPromise
|
var toPromise
|
||||||
|
var debouncePromise
|
||||||
var started = false
|
var started = false
|
||||||
|
|
||||||
var hidden = 'hidden'
|
var hidden = 'hidden'
|
||||||
@ -1067,22 +1068,25 @@ angular.module('izhukov.utils', [])
|
|||||||
}, 10)
|
}, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var debounceTimeout = $rootScope.idle.initial ? 0 : 1000;
|
||||||
if (e && !e.fake_initial) {
|
if (e && !e.fake_initial) {
|
||||||
delete $rootScope.idle.initial;
|
delete $rootScope.idle.initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$timeout.cancel(debouncePromise)
|
||||||
|
|
||||||
if ($rootScope.idle.isIDLE == isIDLE) {
|
if ($rootScope.idle.isIDLE == isIDLE) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('IDLE changed', isIDLE)
|
debouncePromise = $timeout(function () {
|
||||||
$rootScope.$apply(function () {
|
// console.log(dT(), 'IDLE changed', isIDLE)
|
||||||
$rootScope.idle.isIDLE = 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
|
return
|
||||||
}
|
}
|
||||||
var peerID = AppPeersManager.getPeerID(update.peer)
|
var peerID = AppPeersManager.getPeerID(update.peer)
|
||||||
saveDraft(peerID, update.draft, true)
|
saveDraft(peerID, update.draft, {notify: true})
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -4526,18 +4526,18 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveDraft (peerID, apiDraft, notify) {
|
function saveDraft (peerID, apiDraft, options) {
|
||||||
if (notify) {
|
options = options || {}
|
||||||
console.warn(dT(), 'save draft', peerID, apiDraft, notify)
|
|
||||||
}
|
|
||||||
var draft = processApiDraft(apiDraft)
|
var draft = processApiDraft(apiDraft)
|
||||||
cachedServerDrafts[peerID] = draft
|
cachedServerDrafts[peerID] = draft
|
||||||
|
|
||||||
if (notify) {
|
if (options.notify) {
|
||||||
|
console.warn(dT(), 'save draft', peerID, apiDraft, options)
|
||||||
changeDraft(peerID, draft)
|
changeDraft(peerID, draft)
|
||||||
$rootScope.$broadcast('draft_updated', {
|
$rootScope.$broadcast('draft_updated', {
|
||||||
peerID: peerID,
|
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 () {
|
MtpApiManager.invokeApi('messages.saveDraft', params).then(function () {
|
||||||
draftObj.date = tsNow(true) + ServerTimeManager.serverTimeOffset
|
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