parent
88b678689a
commit
937a35332f
@ -50,6 +50,7 @@ angular.module('myApp.services')
|
||||
|
||||
var allDialogsLoaded = false
|
||||
var dialogsOffsetDate = 0
|
||||
var pinnedIndex = 0
|
||||
var dialogsNum = 0
|
||||
|
||||
var migratedFromTo = {}
|
||||
@ -163,6 +164,9 @@ angular.module('myApp.services')
|
||||
if (savedDraft && savedDraft.date > topDate) {
|
||||
topDate = savedDraft.date
|
||||
}
|
||||
if (dialog.pFlags.pinned) {
|
||||
topDate = generateDialogPinnedDate()
|
||||
}
|
||||
|
||||
dialog.index = generateDialogIndex(topDate)
|
||||
dialog.peerID = peerID
|
||||
@ -237,6 +241,7 @@ angular.module('myApp.services')
|
||||
|
||||
var maxSeenIdIncremented = offsetDate ? true : false
|
||||
var hasPrepend = false
|
||||
dialogsResult.dialogs.reverse()
|
||||
angular.forEach(dialogsResult.dialogs, function (dialog) {
|
||||
saveConversation(dialog)
|
||||
if (offsetIndex && dialog.index > offsetIndex) {
|
||||
@ -250,6 +255,7 @@ angular.module('myApp.services')
|
||||
maxSeenIdIncremented = true
|
||||
}
|
||||
})
|
||||
dialogsResult.dialogs.reverse()
|
||||
|
||||
if (!dialogsResult.dialogs.length ||
|
||||
!dialogsResult.count ||
|
||||
@ -266,6 +272,10 @@ angular.module('myApp.services')
|
||||
})
|
||||
}
|
||||
|
||||
function generateDialogPinnedDate() {
|
||||
return 0x7fffff00 + ((pinnedIndex++) & 0xff)
|
||||
}
|
||||
|
||||
function generateDialogIndex (date) {
|
||||
if (date === undefined) {
|
||||
date = tsNow(true) + ServerTimeManager.serverTimeOffset
|
||||
@ -2232,6 +2242,7 @@ angular.module('myApp.services')
|
||||
message.peerString = AppPeersManager.getPeerString(message.peerID)
|
||||
message.unreadCount = unreadCount
|
||||
message.index = dialog && dialog.index || (message.date * 0x10000)
|
||||
message.pinned = dialog && dialog.pFlags.pinned || false
|
||||
|
||||
if (message._ == 'messageService' && message.action.user_id) {
|
||||
message.action.user = AppUsersManager.getUser(message.action.user_id)
|
||||
@ -3018,7 +3029,9 @@ angular.module('myApp.services')
|
||||
if (inboxUnread) {
|
||||
dialog.unread_count++
|
||||
}
|
||||
if (!dialog.pFlags.pinned || !dialog.index) {
|
||||
dialog.index = generateDialogIndex(message.date)
|
||||
}
|
||||
|
||||
newDialogsToHandle[peerID] = dialog
|
||||
if (!newDialogsHandlePromise) {
|
||||
@ -3053,6 +3066,80 @@ angular.module('myApp.services')
|
||||
}
|
||||
break
|
||||
|
||||
case 'updateDialogPinned':
|
||||
var peerID = AppPeersManager.getPeerID(update.peer)
|
||||
var foundDialog = getDialogByPeerID(peerID)
|
||||
|
||||
if (!foundDialog.length || !update.pFlags.pinned) {
|
||||
newDialogsToHandle[peerID] = {reload: true}
|
||||
if (!newDialogsHandlePromise) {
|
||||
newDialogsHandlePromise = $timeout(handleNewDialogs, 0)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
var dialog = foundDialog[0]
|
||||
dialog.index = generateDialogIndex(generateDialogPinnedDate())
|
||||
dialog.pFlags.pinned = true
|
||||
break
|
||||
|
||||
case 'updatePinnedDialogs':
|
||||
var changedDialogs = {}
|
||||
var newPinned = {}
|
||||
if (!update.order) {
|
||||
MtpApiManager.invokeApi('messages.getPinnedDialogs', {}).then(function (dialogsResult) {
|
||||
dialogsResult.dialogs.reverse()
|
||||
applyConversations(dialogsResult)
|
||||
angular.forEach(dialogsResult.dialogs, function (dialog) {
|
||||
newPinned[dialog.peerID] = true
|
||||
})
|
||||
angular.forEach(dialogsStorage.dialogs, function (dialog) {
|
||||
var peerID = dialog.peerID
|
||||
if (dialog.pFlags.pinned && !newPinned[peerID]) {
|
||||
newDialogsToHandle[peerID] = {reload: true}
|
||||
if (!newDialogsHandlePromise) {
|
||||
newDialogsHandlePromise = $timeout(handleNewDialogs, 0)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
break
|
||||
}
|
||||
update.order.reverse()
|
||||
angular.forEach(update.order, function (peer) {
|
||||
var peerID = AppPeersManager.getPeerID(peer)
|
||||
newPinned[peerID] = true
|
||||
|
||||
var foundDialog = getDialogByPeerID(peerID)
|
||||
|
||||
if (!foundDialog.length) {
|
||||
newDialogsToHandle[peerID] = {reload: true}
|
||||
if (!newDialogsHandlePromise) {
|
||||
newDialogsHandlePromise = $timeout(handleNewDialogs, 0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var dialog = foundDialog[0]
|
||||
dialog.index = generateDialogIndex(generateDialogPinnedDate())
|
||||
dialog.pFlags.pinned = true
|
||||
|
||||
newDialogsToHandle[peerID] = dialog
|
||||
if (!newDialogsHandlePromise) {
|
||||
newDialogsHandlePromise = $timeout(handleNewDialogs, 0)
|
||||
}
|
||||
})
|
||||
angular.forEach(dialogsStorage.dialogs, function (dialog) {
|
||||
var peerID = dialog.peerID
|
||||
if (dialog.pFlags.pinned && !newPinned[peerID]) {
|
||||
newDialogsToHandle[peerID] = {reload: true}
|
||||
if (!newDialogsHandlePromise) {
|
||||
newDialogsHandlePromise = $timeout(handleNewDialogs, 0)
|
||||
}
|
||||
}
|
||||
})
|
||||
break
|
||||
|
||||
case 'updateEditMessage':
|
||||
case 'updateEditChannelMessage':
|
||||
var message = update.message
|
||||
@ -3352,7 +3439,10 @@ angular.module('myApp.services')
|
||||
peers: [
|
||||
AppPeersManager.getInputPeerByID(peerID)
|
||||
]
|
||||
}).then(function (dialogsResult) {
|
||||
}).then(applyConversations)
|
||||
}
|
||||
|
||||
function applyConversations(dialogsResult) {
|
||||
AppUsersManager.saveApiUsers(dialogsResult.users)
|
||||
AppChatsManager.saveApiChats(dialogsResult.chats)
|
||||
saveMessages(dialogsResult.messages)
|
||||
@ -3381,7 +3471,6 @@ angular.module('myApp.services')
|
||||
if (hasUpdated) {
|
||||
$rootScope.$broadcast('dialogs_multiupdate', updatedDialogs)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$rootScope.$on('webpage_updated', function (e, eventData) {
|
||||
@ -3421,7 +3510,9 @@ angular.module('myApp.services')
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!dialog.pFlags.pinned) {
|
||||
dialog.index = generateDialogIndex(topDate)
|
||||
}
|
||||
pushDialogToStorage(dialog)
|
||||
|
||||
$rootScope.$broadcast('dialog_draft', {
|
||||
|
@ -1410,6 +1410,26 @@ a.im_dialog_selected {
|
||||
}
|
||||
}
|
||||
|
||||
.im_dialog_pinned {
|
||||
background: red;
|
||||
display: inline-block;
|
||||
float: right;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 5px;
|
||||
overflow: hidden;
|
||||
margin: 12px 0 0;
|
||||
|
||||
a.im_dialog:hover &,
|
||||
a.im_dialog_selected & {
|
||||
background: red;
|
||||
}
|
||||
|
||||
.active & {
|
||||
background-color: red;
|
||||
}
|
||||
}
|
||||
|
||||
.im_dialog_date {
|
||||
color: #b3b3b3;
|
||||
font-size: 0.85em;
|
||||
|
@ -12,6 +12,10 @@
|
||||
class="im_dialog_unread ng-hide"
|
||||
ng-show="dialogMessage.pFlags.out && dialogMessage.pFlags.unread"
|
||||
></i>
|
||||
<i
|
||||
class="im_dialog_pinned ng-hide"
|
||||
ng-show="dialogMessage.pinned && !dialogMessage.unreadCount && !dialogMessage.pFlags.unread"
|
||||
></i>
|
||||
</div>
|
||||
|
||||
<div class="im_dialog_photo pull-left" my-peer-photolink="::dialogMessage.peerID" img-class="im_dialog_photo" watch="true"></div>
|
||||
|
@ -12,6 +12,10 @@
|
||||
class="im_dialog_unread ng-hide"
|
||||
ng-show="dialogMessage.pFlags.out && dialogMessage.pFlags.unread"
|
||||
></i>
|
||||
<i
|
||||
class="im_dialog_pinned ng-hide"
|
||||
ng-show="dialogMessage.pinned && !dialogMessage.unreadCount && !dialogMessage.pFlags.unread"
|
||||
></i>
|
||||
</div>
|
||||
|
||||
<div class="im_dialog_photo pull-left" my-peer-photolink="::dialogMessage.peerID" img-class="im_dialog_photo" watch="true"></div>
|
||||
|
Loading…
Reference in New Issue
Block a user