Browse Source

Fixed message unread

master
Igor Zhukov 8 years ago
parent
commit
f10033a1af
  1. 6
      app/js/lib/mtproto.js
  2. 19
      app/js/messages_manager.js
  3. 3
      app/js/services.js
  4. 4
      app/partials/desktop/message.html
  5. 4
      app/partials/mobile/message.html

6
app/js/lib/mtproto.js

@ -1470,7 +1470,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -1470,7 +1470,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
var self = this
Storage.get('dc').then(function (baseDcID) {
if (baseDcID == self.dcID && !self.upload && updatesProcessor) {
updatesProcessor(message)
updatesProcessor(message, true)
}
})
break
@ -1551,7 +1551,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -1551,7 +1551,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
// console.log('Update', message)
if (updatesProcessor) {
updatesProcessor(message)
updatesProcessor(message, true)
}
break
@ -1561,7 +1561,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -1561,7 +1561,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
function startAll () {
if (akStopped) {
akStopped = false
updatesProcessor({_: 'new_session_created'})
updatesProcessor({_: 'new_session_created'}, true)
}
}

19
app/js/messages_manager.js

@ -1118,15 +1118,15 @@ angular.module('myApp.services') @@ -1118,15 +1118,15 @@ angular.module('myApp.services')
return
}
var toPeerID = AppPeersManager.getPeerID(apiMessage.to_id)
var peerID = getMessagePeer(apiMessage)
var isChannel = apiMessage.to_id._ == 'peerChannel'
var channelID = isChannel ? -toPeerID : 0
var channelID = isChannel ? -peerID : 0
var isBroadcast = isChannel && !AppChatsManager.isMegagroup(channelID)
var mid = AppMessagesIDsManager.getFullMessageID(apiMessage.id, channelID)
apiMessage.mid = mid
var dialog = getDialogByPeerID(toPeerID)[0]
var dialog = getDialogByPeerID(peerID)[0]
if (dialog && mid > 0) {
var dialogKey = apiMessage.pFlags.out
? 'read_outbox_max_id'
@ -1137,6 +1137,7 @@ angular.module('myApp.services') @@ -1137,6 +1137,7 @@ angular.module('myApp.services')
else if (options.isNew) {
apiMessage.pFlags.unread = true
}
// console.log(dT(), 'msg unread', mid, apiMessage.pFlags.out, dialog && dialog[apiMessage.pFlags.out ? 'read_outbox_max_id' : 'read_inbox_max_id'])
if (apiMessage.reply_to_msg_id) {
apiMessage.reply_to_mid = AppMessagesIDsManager.getFullMessageID(apiMessage.reply_to_msg_id, channelID)
@ -1150,8 +1151,8 @@ angular.module('myApp.services') @@ -1150,8 +1151,8 @@ angular.module('myApp.services')
fwdHeader.date -= ServerTimeManager.serverTimeOffset
}
apiMessage.toID = toPeerID
apiMessage.fromID = apiMessage.pFlags.post ? toPeerID : apiMessage.from_id
apiMessage.peerID = peerID
apiMessage.fromID = apiMessage.pFlags.post ? peerID : apiMessage.from_id
apiMessage.signID = apiMessage.pFlags.post && apiMessage.from_id ||
fwdHeader && fwdHeader.channel_id && fwdHeader.from_id
@ -1483,7 +1484,7 @@ angular.module('myApp.services') @@ -1483,7 +1484,7 @@ angular.module('myApp.services')
apiFileName = 'document.' + file.type.split('/')[1]
}
console.log(attachType, apiFileName, file.type)
// console.log(attachType, apiFileName, file.type)
if (historyStorage === undefined) {
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []}
@ -2658,6 +2659,7 @@ angular.module('myApp.services') @@ -2658,6 +2659,7 @@ angular.module('myApp.services')
}
saveMessages([message], {isNew: true})
// console.warn(dT(), 'message unread', message.mid, message.pFlags.unread)
if (historyStorage !== undefined) {
var history = historyStorage.history
@ -2821,6 +2823,8 @@ angular.module('myApp.services') @@ -2821,6 +2823,8 @@ angular.module('myApp.services')
var messageID, message
var i
// console.warn(dT(), 'read', peerID, isOut ? 'out' : 'in', maxID)
if (peerID > 0 && isOut) {
AppUsersManager.forceUserOnline(peerID)
}
@ -2838,7 +2842,7 @@ angular.module('myApp.services') @@ -2838,7 +2842,7 @@ angular.module('myApp.services')
if (!message.pFlags.unread) {
break
}
// console.log('read', messageID, message.pFlags.unread, message)
// console.warn('read', messageID, message.pFlags.unread, message)
if (message && message.pFlags.unread) {
message.pFlags.unread = false
if (messagesForHistory[messageID]) {
@ -2869,6 +2873,7 @@ angular.module('myApp.services') @@ -2869,6 +2873,7 @@ angular.module('myApp.services')
}
if (newUnreadCount !== false) {
// console.warn(dT(), 'cnt', peerID, newUnreadCount)
$rootScope.$broadcast('dialog_unread', {peerID: peerID, count: newUnreadCount})
}
if (foundAffected) {

3
app/js/services.js

@ -2909,7 +2909,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2909,7 +2909,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
}
function processUpdateMessage (updateMessage) {
function processUpdateMessage (updateMessage, fromMTProto) {
// return forceGetDifference()
var processOpts = {
date: updateMessage.date,
seq: updateMessage.seq,

4
app/partials/desktop/message.html

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
<div class="im_bot_intro_message" ng-bind-html="::historyMessage.action.rDescription"></div>
</div>
<div ng-switch-default class="im_service_message">
<a class="im_message_author" ng-if="::historyMessage.fromID > 0" my-peer-link="historyMessage.fromID" short="historyMessage.toID > 0" color="historyMessage.toID < 0" no-watch="true"></a>
<a class="im_message_author" ng-if="::historyMessage.fromID > 0" my-peer-link="historyMessage.fromID" short="historyMessage.peerID > 0" color="historyMessage.peerID < 0" no-watch="true"></a>
<span class="im_message_service" my-service-message></span>
</div>
@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
<div class="im_message_body" ng-class="::{im_message_body_media: historyMessage._ == 'message' &amp;&amp; historyMessage.media ? true : false}">
<span class="im_message_author_wrap">
<span class="copyonly">[<span ng-bind="::historyMessage.date | time"></span>] </span><a class="im_message_author" my-peer-link="historyMessage.fromID" short="historyMessage.toID > 0" color="historyMessage.toID < 0" no-watch="true"></a><a ng-if="::historyMessage.viaBotID && !historyMessage.fwdFromID" class="im_message_author_via" ng-click="selectInlineBot(historyMessage.viaBotID, $event)"><span class="copyonly">&nbsp;</span><span my-i18n="message_via_bot"><my-i18n-param name="bot"><span class="im_message_fwd_author" my-peer-link="historyMessage.viaBotID" username="true" no-watch="true"></span></my-i18n-param></span></a><span class="copyonly">:</span>
<span class="copyonly">[<span ng-bind="::historyMessage.date | time"></span>] </span><a class="im_message_author" my-peer-link="historyMessage.fromID" short="historyMessage.peerID > 0" color="historyMessage.peerID < 0" no-watch="true"></a><a ng-if="::historyMessage.viaBotID && !historyMessage.fwdFromID" class="im_message_author_via" ng-click="selectInlineBot(historyMessage.viaBotID, $event)"><span class="copyonly">&nbsp;</span><span my-i18n="message_via_bot"><my-i18n-param name="bot"><span class="im_message_fwd_author" my-peer-link="historyMessage.viaBotID" username="true" no-watch="true"></span></my-i18n-param></span></a><span class="copyonly">:</span>
</span>

4
app/partials/mobile/message.html

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
<div class="im_bot_intro_message" ng-bind-html="::historyMessage.action.rDescription"></div>
</div>
<div ng-switch-default class="im_service_message">
<a class="im_message_author" ng-if="::historyMessage.fromID > 0" my-peer-link="historyMessage.fromID" short="historyMessage.toID > 0" color="historyMessage.toID < 0" no-watch="true"></a>
<a class="im_message_author" ng-if="::historyMessage.fromID > 0" my-peer-link="historyMessage.fromID" short="historyMessage.peerID > 0" color="historyMessage.peerID < 0" no-watch="true"></a>
<span class="im_message_service" my-service-message></span>
</div>
@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
<div my-message-body="historyMessage">
<div class="im_message_body" ng-class="::{im_message_body_media: historyMessage._ == 'message' &amp;&amp; historyMessage.media && historyMessage.media._ != 'messageMediaWebPage' && !historyMessage.media.rCaption && !historyMessage.viaBotID ? true : false}">
<a class="im_message_author" my-peer-link="historyMessage.fromID" short="historyMessage.toID > 0" color="historyMessage.toID < 0" no-watch="true"></a>
<a class="im_message_author" my-peer-link="historyMessage.fromID" short="historyMessage.peerID > 0" color="historyMessage.peerID < 0" no-watch="true"></a>
<a ng-if="::historyMessage.viaBotID && !historyMessage.fwdFromID" class="im_message_author_via" my-i18n="message_via_bot" ng-click="selectInlineBot(historyMessage.viaBotID, $event)"><my-i18n-param name="bot"><span class="im_message_fwd_author" my-peer-link="historyMessage.viaBotID" username="true" no-watch="true"></span></my-i18n-param></a>
<a class="im_message_reply_wrap" my-reply-message="::historyMessage.reply_to_mid" ng-if="::historyMessage.reply_to_mid"></a>

Loading…
Cancel
Save