Browse Source

Fixed group to supergroup migrate issue

master
Igor Zhukov 7 years ago
parent
commit
a6fe495c07
  1. 7
      app/js/controllers.js
  2. 10
      app/js/messages_manager.js
  3. 12
      app/js/services.js

7
app/js/controllers.js

@ -1293,6 +1293,13 @@ angular.module('myApp.controllers', ['myApp.i18n'])
function applyDialogSelect (newDialog, oldDialog) { function applyDialogSelect (newDialog, oldDialog) {
peerID = $rootScope.selectedPeerID = newDialog.peerID peerID = $rootScope.selectedPeerID = newDialog.peerID
var migratedToPeer = AppPeersManager.getPeerMigratedTo(peerID)
if (migratedToPeer) {
$rootScope.$broadcast('history_focus', {
peerString: AppPeersManager.getPeerString(migratedToPeer)
})
return
}
$scope.historyFilter.mediaType = false $scope.historyFilter.mediaType = false
AppPeersManager.getInputPeer(newDialog.peer || $scope.curDialog.peer || '') AppPeersManager.getInputPeer(newDialog.peer || $scope.curDialog.peer || '')

10
app/js/messages_manager.js

@ -1527,9 +1527,9 @@ angular.module('myApp.services')
} }
if (migrateFrom && if (migrateFrom &&
migrateTo && migrateTo &&
!migratedFromTo[migrateFrom] && !migratedFromTo[migrateFrom] &&
!migratedToFrom[migrateTo]) { !migratedToFrom[migrateTo]) {
migrateChecks(migrateFrom, migrateTo) migrateChecks(migrateFrom, migrateTo)
} }
} }
@ -1552,6 +1552,7 @@ angular.module('myApp.services')
if (!angular.isString(text)) { if (!angular.isString(text)) {
return return
} }
peerID = AppPeersManager.getPeerMigratedTo(peerID) || peerID
options = options || {} options = options || {}
var entities = options.entities || [] var entities = options.entities || []
if (!options.viaBotID) { if (!options.viaBotID) {
@ -1740,6 +1741,7 @@ angular.module('myApp.services')
} }
function sendFile (peerID, file, options) { function sendFile (peerID, file, options) {
peerID = AppPeersManager.getPeerMigratedTo(peerID) || peerID
options = options || {} options = options || {}
var messageID = tempID-- var messageID = tempID--
var randomID = [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)] var randomID = [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)]
@ -1924,6 +1926,7 @@ angular.module('myApp.services')
} }
function sendOther (peerID, inputMedia, options) { function sendOther (peerID, inputMedia, options) {
peerID = AppPeersManager.getPeerMigratedTo(peerID) || peerID
options = options || {} options = options || {}
var messageID = tempID-- var messageID = tempID--
@ -2126,6 +2129,7 @@ angular.module('myApp.services')
} }
function forwardMessages (peerID, mids, options) { function forwardMessages (peerID, mids, options) {
peerID = AppPeersManager.getPeerMigratedTo(peerID) || peerID
mids = mids.sort() mids = mids.sort()
options = options || {} options = options || {}

12
app/js/services.js

@ -1019,6 +1019,17 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
: AppChatsManager.getChatPhoto(-peerID) : AppChatsManager.getChatPhoto(-peerID)
} }
function getPeerMigratedTo(peerID) {
if (peerID >= 0) {
return false
}
var chat = AppChatsManager.getChat(-peerID)
if (chat && chat.migrated_to && chat.pFlags.deactivated) {
return getPeerID(chat.migrated_to)
}
return false
}
function isChannel (peerID) { function isChannel (peerID) {
return (peerID < 0) && AppChatsManager.isChannel(-peerID) return (peerID < 0) && AppChatsManager.isChannel(-peerID)
} }
@ -1048,6 +1059,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
getPeerID: getPeerID, getPeerID: getPeerID,
getPeer: getPeer, getPeer: getPeer,
getPeerPhoto: getPeerPhoto, getPeerPhoto: getPeerPhoto,
getPeerMigratedTo: getPeerMigratedTo,
resolveUsername: resolveUsername, resolveUsername: resolveUsername,
isChannel: isChannel, isChannel: isChannel,
isAnyGroup: isAnyGroup, isAnyGroup: isAnyGroup,

Loading…
Cancel
Save