Improved PUSH-notification when the app is launched
Possbly fixes #1301
This commit is contained in:
parent
a862c17bac
commit
35f065dee1
@ -35,11 +35,12 @@ angular.module('myApp.services')
|
|||||||
var incrementMessageViewsTimeout = false
|
var incrementMessageViewsTimeout = false
|
||||||
|
|
||||||
var maxSeenID = false
|
var maxSeenID = false
|
||||||
if (Config.Modes.packed) {
|
|
||||||
Storage.get('max_seen_msg').then(function (maxID) {
|
Storage.get('max_seen_msg').then(function (maxID) {
|
||||||
maxSeenID = maxID || 0
|
if (maxID &&
|
||||||
})
|
!AppMessagesIDsManager.getMessageIDInfo(maxID)[1]) {
|
||||||
|
maxSeenID = maxID
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
var dateOrTimeFilter = $filter('dateOrTime')
|
var dateOrTimeFilter = $filter('dateOrTime')
|
||||||
var fwdMessagesPluralize = _.pluralize('conversation_forwarded_X_messages')
|
var fwdMessagesPluralize = _.pluralize('conversation_forwarded_X_messages')
|
||||||
@ -190,15 +191,16 @@ angular.module('myApp.services')
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
Config.Modes.packed &&
|
||||||
!channelID &&
|
!channelID &&
|
||||||
dialog.unread_count > 0 &&
|
dialog.unread_count > 0 &&
|
||||||
maxSeenID &&
|
maxSeenID &&
|
||||||
dialog.top_message > maxSeenID
|
dialog.top_message > maxSeenID &&
|
||||||
|
message.pFlags.unread &&
|
||||||
|
!message.pFlags.out &&
|
||||||
|
!message.pFlags.silent
|
||||||
) {
|
) {
|
||||||
var notifyPeer = message.flags & 16 ? message.from_id : peerID
|
var notifyPeer = message.flags & 16 ? message.from_id : peerID
|
||||||
if (message.pFlags.unread &&
|
|
||||||
!message.pFlags.out &&
|
|
||||||
!message.pFlags.silent) {
|
|
||||||
NotificationsManager.getPeerMuted(notifyPeer).then(function (muted) {
|
NotificationsManager.getPeerMuted(notifyPeer).then(function (muted) {
|
||||||
if (!muted) {
|
if (!muted) {
|
||||||
notifyAboutMessage(message)
|
notifyAboutMessage(message)
|
||||||
@ -206,7 +208,6 @@ angular.module('myApp.services')
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function getTopMessages (limit) {
|
function getTopMessages (limit) {
|
||||||
var first = true
|
var first = true
|
||||||
@ -2595,11 +2596,15 @@ angular.module('myApp.services')
|
|||||||
}
|
}
|
||||||
|
|
||||||
function incrementMaxSeenID (maxID) {
|
function incrementMaxSeenID (maxID) {
|
||||||
if (maxSeenID !== false && maxID && maxID > maxSeenID) {
|
if (!maxID || !(!maxSeenID || maxID > maxSeenID)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
Storage.set({
|
Storage.set({
|
||||||
max_seen_msg: maxID
|
max_seen_msg: maxID
|
||||||
})
|
})
|
||||||
}
|
MtpApiManager.invokeApi('messages.receivedMessages', {
|
||||||
|
max_id: maxID
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function notifyAboutMessage (message, options) {
|
function notifyAboutMessage (message, options) {
|
||||||
@ -2972,7 +2977,9 @@ angular.module('myApp.services')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!AppPeersManager.isChannel(peerID)) {
|
||||||
incrementMaxSeenID(message.id)
|
incrementMaxSeenID(message.id)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'updateEditMessage':
|
case 'updateEditMessage':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user