|
|
@ -174,7 +174,7 @@ export class AppMessagesManager { |
|
|
|
public newMessagesToHandle: {[peerId: string]: Set<number>} = {}; |
|
|
|
public newMessagesToHandle: {[peerId: string]: Set<number>} = {}; |
|
|
|
public newDialogsHandlePromise = 0; |
|
|
|
public newDialogsHandlePromise = 0; |
|
|
|
public newDialogsToHandle: {[peerId: string]: {reload: true} | Dialog} = {}; |
|
|
|
public newDialogsToHandle: {[peerId: string]: {reload: true} | Dialog} = {}; |
|
|
|
public newUpdatesAfterReloadToHandle: {[peerId: string]: Set<any>} = {}; |
|
|
|
public newUpdatesAfterReloadToHandle: {[peerId: string]: Set<Update>} = {}; |
|
|
|
|
|
|
|
|
|
|
|
private notificationsHandlePromise = 0; |
|
|
|
private notificationsHandlePromise = 0; |
|
|
|
private notificationsToHandle: {[peerId: string]: { |
|
|
|
private notificationsToHandle: {[peerId: string]: { |
|
|
@ -207,10 +207,58 @@ export class AppMessagesManager { |
|
|
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
|
this.dialogsStorage = new DialogsStorage(this, appChatsManager, appPeersManager, serverTimeManager); |
|
|
|
this.dialogsStorage = new DialogsStorage(this, appChatsManager, appPeersManager, serverTimeManager); |
|
|
|
this.filtersStorage = new FiltersStorage(this, appPeersManager, appUsersManager, appNotificationsManager, /* apiManager, */ rootScope); |
|
|
|
this.filtersStorage = new FiltersStorage(this, appPeersManager, appUsersManager, appNotificationsManager, apiUpdatesManager, /* apiManager, */ rootScope); |
|
|
|
|
|
|
|
|
|
|
|
rootScope.on('apiUpdate', (e) => { |
|
|
|
rootScope.addMultipleEventsListeners({ |
|
|
|
this.handleUpdate(e); |
|
|
|
updateMessageID: this.onUpdateMessageId, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateNewDiscussionMessage: this.onUpdateNewMessage, |
|
|
|
|
|
|
|
updateNewMessage: this.onUpdateNewMessage, |
|
|
|
|
|
|
|
updateNewChannelMessage: this.onUpdateNewMessage, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateDialogUnreadMark: this.onUpdateDialogUnreadMark, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateFolderPeers: this.onUpdateFolderPeers, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateDialogPinned: this.onUpdateDialogPinned, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updatePinnedDialogs: this.onUpdatePinnedDialogs, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateEditMessage: this.onUpdateEditMessage, |
|
|
|
|
|
|
|
updateEditChannelMessage: this.onUpdateEditMessage, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateReadChannelDiscussionInbox: this.onUpdateReadHistory, |
|
|
|
|
|
|
|
updateReadChannelDiscussionOutbox: this.onUpdateReadHistory, |
|
|
|
|
|
|
|
updateReadHistoryInbox: this.onUpdateReadHistory, |
|
|
|
|
|
|
|
updateReadHistoryOutbox: this.onUpdateReadHistory, |
|
|
|
|
|
|
|
updateReadChannelInbox: this.onUpdateReadHistory, |
|
|
|
|
|
|
|
updateReadChannelOutbox: this.onUpdateReadHistory, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateChannelReadMessagesContents: this.onUpdateReadMessagesContents, |
|
|
|
|
|
|
|
updateReadMessagesContents: this.onUpdateReadMessagesContents, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateChannelAvailableMessages: this.onUpdateChannelAvailableMessages, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateDeleteMessages: this.onUpdateDeleteMessages, |
|
|
|
|
|
|
|
updateDeleteChannelMessages: this.onUpdateDeleteMessages, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateChannel: this.onUpdateChannel, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
updateChannelReload: this.onUpdateChannelReload, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateChannelMessageViews: this.onUpdateChannelMessageViews, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateServiceNotification: this.onUpdateServiceNotification, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updatePinnedMessages: this.onUpdatePinnedMessages, |
|
|
|
|
|
|
|
updatePinnedChannelMessages: this.onUpdatePinnedMessages, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateNotifySettings: this.onUpdateNotifySettings, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateNewScheduledMessage: this.onUpdateNewScheduledMessage, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateDeleteScheduledMessages: this.onUpdateDeleteScheduledMessages |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// ! Invalidate notify settings, can optimize though
|
|
|
|
// ! Invalidate notify settings, can optimize though
|
|
|
@ -2900,7 +2948,7 @@ export class AppMessagesManager { |
|
|
|
}).then(bool => { |
|
|
|
}).then(bool => { |
|
|
|
if(bool) { |
|
|
|
if(bool) { |
|
|
|
const pFlags: Update.updateDialogPinned['pFlags'] = pinned ? {pinned} : {}; |
|
|
|
const pFlags: Update.updateDialogPinned['pFlags'] = pinned ? {pinned} : {}; |
|
|
|
this.handleUpdate({ |
|
|
|
this.onUpdateDialogPinned({ |
|
|
|
_: 'updateDialogPinned', |
|
|
|
_: 'updateDialogPinned', |
|
|
|
peer: appPeersManager.getDialogPeer(peerId), |
|
|
|
peer: appPeersManager.getDialogPeer(peerId), |
|
|
|
folder_id: filterId, |
|
|
|
folder_id: filterId, |
|
|
@ -2921,7 +2969,7 @@ export class AppMessagesManager { |
|
|
|
}).then(bool => { |
|
|
|
}).then(bool => { |
|
|
|
if(bool) { |
|
|
|
if(bool) { |
|
|
|
const pFlags: Update.updateDialogUnreadMark['pFlags'] = unread ? {unread} : {}; |
|
|
|
const pFlags: Update.updateDialogUnreadMark['pFlags'] = unread ? {unread} : {}; |
|
|
|
this.handleUpdate({ |
|
|
|
this.onUpdateDialogUnreadMark({ |
|
|
|
_: 'updateDialogUnreadMark', |
|
|
|
_: 'updateDialogUnreadMark', |
|
|
|
peer: appPeersManager.getDialogPeer(peerId), |
|
|
|
peer: appPeersManager.getDialogPeer(peerId), |
|
|
|
pFlags |
|
|
|
pFlags |
|
|
@ -3059,7 +3107,7 @@ export class AppMessagesManager { |
|
|
|
|
|
|
|
|
|
|
|
if(this.newUpdatesAfterReloadToHandle[peerId] !== undefined) { |
|
|
|
if(this.newUpdatesAfterReloadToHandle[peerId] !== undefined) { |
|
|
|
for(const update of this.newUpdatesAfterReloadToHandle[peerId]) { |
|
|
|
for(const update of this.newUpdatesAfterReloadToHandle[peerId]) { |
|
|
|
this.handleUpdate(update); |
|
|
|
apiUpdatesManager.saveUpdate(update); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
delete this.newUpdatesAfterReloadToHandle[peerId]; |
|
|
|
delete this.newUpdatesAfterReloadToHandle[peerId]; |
|
|
@ -3927,13 +3975,7 @@ export class AppMessagesManager { |
|
|
|
this.notificationsToHandle = {}; |
|
|
|
this.notificationsToHandle = {}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public handleUpdate(update: Update) { |
|
|
|
private onUpdateMessageId = (update: Update.updateMessageID) => { |
|
|
|
/* if(DEBUG) { |
|
|
|
|
|
|
|
this.log.debug('handleUpdate', update._, update); |
|
|
|
|
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(update._) { |
|
|
|
|
|
|
|
case 'updateMessageID': { |
|
|
|
|
|
|
|
const randomId = update.random_id; |
|
|
|
const randomId = update.random_id; |
|
|
|
const pendingData = this.pendingByRandomId[randomId]; |
|
|
|
const pendingData = this.pendingByRandomId[randomId]; |
|
|
|
//this.log('AMM updateMessageID:', update, pendingData);
|
|
|
|
//this.log('AMM updateMessageID:', update, pendingData);
|
|
|
@ -3954,13 +3996,9 @@ export class AppMessagesManager { |
|
|
|
this.pendingByMessageId[mid] = randomId; |
|
|
|
this.pendingByMessageId[mid] = randomId; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
private onUpdateNewMessage = (update: Update.updateNewDiscussionMessage | Update.updateNewMessage | Update.updateNewChannelMessage) => { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateNewDiscussionMessage': |
|
|
|
|
|
|
|
case 'updateNewMessage': |
|
|
|
|
|
|
|
case 'updateNewChannelMessage': { |
|
|
|
|
|
|
|
const message = update.message as MyMessage; |
|
|
|
const message = update.message as MyMessage; |
|
|
|
const peerId = this.getMessagePeer(message); |
|
|
|
const peerId = this.getMessagePeer(message); |
|
|
|
const storage = this.getMessagesStorage(peerId); |
|
|
|
const storage = this.getMessagesStorage(peerId); |
|
|
@ -3980,7 +4018,7 @@ export class AppMessagesManager { |
|
|
|
message |
|
|
|
message |
|
|
|
} as Update.updateNewDiscussionMessage; |
|
|
|
} as Update.updateNewDiscussionMessage; |
|
|
|
|
|
|
|
|
|
|
|
this.handleUpdate(update); |
|
|
|
this.onUpdateNewMessage(update); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!foundDialog.length && !isLocalThreadUpdate) { |
|
|
|
if(!foundDialog.length && !isLocalThreadUpdate) { |
|
|
@ -4000,7 +4038,7 @@ export class AppMessagesManager { |
|
|
|
const set = this.newUpdatesAfterReloadToHandle[peerId] ?? (this.newUpdatesAfterReloadToHandle[peerId] = new Set()); |
|
|
|
const set = this.newUpdatesAfterReloadToHandle[peerId] ?? (this.newUpdatesAfterReloadToHandle[peerId] = new Set()); |
|
|
|
if(set.has(update)) { |
|
|
|
if(set.has(update)) { |
|
|
|
this.log.error('here we go again', peerId); |
|
|
|
this.log.error('here we go again', peerId); |
|
|
|
break; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.newDialogsToHandle[peerId] = {reload: true}; |
|
|
|
this.newDialogsToHandle[peerId] = {reload: true}; |
|
|
@ -4008,13 +4046,13 @@ export class AppMessagesManager { |
|
|
|
this.newUpdatesAfterReloadToHandle[peerId].add(update); |
|
|
|
this.newUpdatesAfterReloadToHandle[peerId].add(update); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* if(update._ === 'updateNewChannelMessage') { |
|
|
|
/* if(update._ === 'updateNewChannelMessage') { |
|
|
|
const chat = appChatsManager.getChat(-peerId); |
|
|
|
const chat = appChatsManager.getChat(-peerId); |
|
|
|
if(chat.pFlags && (chat.pFlags.left || chat.pFlags.kicked)) { |
|
|
|
if(chat.pFlags && (chat.pFlags.left || chat.pFlags.kicked)) { |
|
|
|
break; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} */ |
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
|
@ -4070,7 +4108,7 @@ export class AppMessagesManager { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(isLocalThreadUpdate) { |
|
|
|
if(isLocalThreadUpdate) { |
|
|
|
break; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const dialog = foundDialog[0]; |
|
|
|
const dialog = foundDialog[0]; |
|
|
@ -4107,11 +4145,9 @@ export class AppMessagesManager { |
|
|
|
this.notificationsHandlePromise = window.setTimeout(this.handleNotifications, 0); |
|
|
|
this.notificationsHandlePromise = window.setTimeout(this.handleNotifications, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
private onUpdateDialogUnreadMark = (update: Update.updateDialogUnreadMark) => { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateDialogUnreadMark': { |
|
|
|
|
|
|
|
//this.log('updateDialogUnreadMark', update);
|
|
|
|
//this.log('updateDialogUnreadMark', update);
|
|
|
|
const peerId = appPeersManager.getPeerId((update.peer as DialogPeer.dialogPeer).peer); |
|
|
|
const peerId = appPeersManager.getPeerId((update.peer as DialogPeer.dialogPeer).peer); |
|
|
|
const foundDialog = this.getDialogByPeerId(peerId); |
|
|
|
const foundDialog = this.getDialogByPeerId(peerId); |
|
|
@ -4130,11 +4166,10 @@ export class AppMessagesManager { |
|
|
|
|
|
|
|
|
|
|
|
rootScope.broadcast('dialogs_multiupdate', {peerId: dialog}); |
|
|
|
rootScope.broadcast('dialogs_multiupdate', {peerId: dialog}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
// only 0 and 1 folders
|
|
|
|
} |
|
|
|
private onUpdateFolderPeers = (update: Update.updateFolderPeers) => { |
|
|
|
|
|
|
|
|
|
|
|
case 'updateFolderPeers': { // only 0 and 1 folders
|
|
|
|
|
|
|
|
//this.log('updateFolderPeers', update);
|
|
|
|
//this.log('updateFolderPeers', update);
|
|
|
|
const peers = update.folder_peers; |
|
|
|
const peers = update.folder_peers; |
|
|
|
|
|
|
|
|
|
|
@ -4161,10 +4196,9 @@ export class AppMessagesManager { |
|
|
|
this.dialogsStorage.pushDialog(dialog); // need for simultaneously updatePinnedDialogs
|
|
|
|
this.dialogsStorage.pushDialog(dialog); // need for simultaneously updatePinnedDialogs
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
break; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateDialogPinned': { |
|
|
|
private onUpdateDialogPinned = (update: Update.updateDialogPinned) => { |
|
|
|
const folderId = update.folder_id ?? 0; |
|
|
|
const folderId = update.folder_id ?? 0; |
|
|
|
//this.log('updateDialogPinned', update);
|
|
|
|
//this.log('updateDialogPinned', update);
|
|
|
|
const peerId = appPeersManager.getPeerId((update.peer as DialogPeer.dialogPeer).peer); |
|
|
|
const peerId = appPeersManager.getPeerId((update.peer as DialogPeer.dialogPeer).peer); |
|
|
@ -4196,11 +4230,9 @@ export class AppMessagesManager { |
|
|
|
|
|
|
|
|
|
|
|
this.dialogsStorage.generateIndexForDialog(dialog); |
|
|
|
this.dialogsStorage.generateIndexForDialog(dialog); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
private onUpdatePinnedDialogs = (update: Update.updatePinnedDialogs) => { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updatePinnedDialogs': { |
|
|
|
|
|
|
|
const folderId = update.folder_id ?? 0; |
|
|
|
const folderId = update.folder_id ?? 0; |
|
|
|
|
|
|
|
|
|
|
|
const handleOrder = (order: number[]) => { |
|
|
|
const handleOrder = (order: number[]) => { |
|
|
@ -4264,24 +4296,21 @@ export class AppMessagesManager { |
|
|
|
}); */ |
|
|
|
}); */ |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//this.log('before order:', this.dialogsStorage[0].map(d => d.peerId));
|
|
|
|
//this.log('before order:', this.dialogsStorage[0].map(d => d.peerId));
|
|
|
|
|
|
|
|
|
|
|
|
handleOrder(update.order.map(peer => appPeersManager.getPeerId((peer as DialogPeer.dialogPeer).peer))); |
|
|
|
handleOrder(update.order.map(peer => appPeersManager.getPeerId((peer as DialogPeer.dialogPeer).peer))); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
private onUpdateEditMessage = (update: Update.updateEditMessage | Update.updateEditChannelMessage) => { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateEditMessage': |
|
|
|
|
|
|
|
case 'updateEditChannelMessage': { |
|
|
|
|
|
|
|
const message = update.message as MyMessage; |
|
|
|
const message = update.message as MyMessage; |
|
|
|
const peerId = this.getMessagePeer(message); |
|
|
|
const peerId = this.getMessagePeer(message); |
|
|
|
const mid = this.generateMessageId(message.id); |
|
|
|
const mid = this.generateMessageId(message.id); |
|
|
|
const storage = this.getMessagesStorage(peerId); |
|
|
|
const storage = this.getMessagesStorage(peerId); |
|
|
|
if(storage[mid] === undefined) { |
|
|
|
if(storage[mid] === undefined) { |
|
|
|
break; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// console.trace(dT(), 'edit message', message)
|
|
|
|
// console.trace(dT(), 'edit message', message)
|
|
|
@ -4312,15 +4341,11 @@ export class AppMessagesManager { |
|
|
|
rootScope.broadcast('dialogs_multiupdate', updatedDialogs); |
|
|
|
rootScope.broadcast('dialogs_multiupdate', updatedDialogs); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateReadChannelDiscussionInbox': |
|
|
|
private onUpdateReadHistory = (update: Update.updateReadChannelDiscussionInbox | Update.updateReadChannelDiscussionOutbox |
|
|
|
case 'updateReadChannelDiscussionOutbox': |
|
|
|
| Update.updateReadHistoryInbox | Update.updateReadHistoryOutbox |
|
|
|
case 'updateReadHistoryInbox': |
|
|
|
| Update.updateReadChannelInbox | Update.updateReadChannelOutbox) => { |
|
|
|
case 'updateReadHistoryOutbox': |
|
|
|
|
|
|
|
case 'updateReadChannelInbox': |
|
|
|
|
|
|
|
case 'updateReadChannelOutbox': { |
|
|
|
|
|
|
|
const channelId = (update as Update.updateReadChannelInbox).channel_id; |
|
|
|
const channelId = (update as Update.updateReadChannelInbox).channel_id; |
|
|
|
const maxId = this.generateMessageId((update as Update.updateReadChannelInbox).max_id || (update as Update.updateReadChannelDiscussionInbox).read_max_id); |
|
|
|
const maxId = this.generateMessageId((update as Update.updateReadChannelInbox).max_id || (update as Update.updateReadChannelDiscussionInbox).read_max_id); |
|
|
|
const threadId = this.generateMessageId((update as Update.updateReadChannelDiscussionInbox).top_msg_id); |
|
|
|
const threadId = this.generateMessageId((update as Update.updateReadChannelDiscussionInbox).top_msg_id); |
|
|
@ -4420,12 +4445,9 @@ export class AppMessagesManager { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
private onUpdateReadMessagesContents = (update: Update.updateChannelReadMessagesContents | Update.updateReadMessagesContents) => { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateChannelReadMessagesContents': |
|
|
|
|
|
|
|
case 'updateReadMessagesContents': { |
|
|
|
|
|
|
|
const channelId = (update as Update.updateChannelReadMessagesContents).channel_id; |
|
|
|
const channelId = (update as Update.updateChannelReadMessagesContents).channel_id; |
|
|
|
const mids = (update as Update.updateReadMessagesContents).messages.map(id => this.generateMessageId(id)); |
|
|
|
const mids = (update as Update.updateReadMessagesContents).messages.map(id => this.generateMessageId(id)); |
|
|
|
const peerId = channelId ? -channelId : this.getMessageById(mids[0]).peerId; |
|
|
|
const peerId = channelId ? -channelId : this.getMessageById(mids[0]).peerId; |
|
|
@ -4437,10 +4459,9 @@ export class AppMessagesManager { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rootScope.broadcast('messages_media_read', {peerId, mids}); |
|
|
|
rootScope.broadcast('messages_media_read', {peerId, mids}); |
|
|
|
break; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateChannelAvailableMessages': { |
|
|
|
private onUpdateChannelAvailableMessages = (update: Update.updateChannelAvailableMessages) => { |
|
|
|
const channelId: number = update.channel_id; |
|
|
|
const channelId: number = update.channel_id; |
|
|
|
const messages: number[] = []; |
|
|
|
const messages: number[] = []; |
|
|
|
const peerId: number = -channelId; |
|
|
|
const peerId: number = -channelId; |
|
|
@ -4454,17 +4475,17 @@ export class AppMessagesManager { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
(update as any as Update.updateDeleteChannelMessages).messages = messages; |
|
|
|
(update as any as Update.updateDeleteChannelMessages).messages = messages; |
|
|
|
} |
|
|
|
this.onUpdateDeleteMessages(update as any as Update.updateDeleteChannelMessages); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
case 'updateDeleteMessages': |
|
|
|
private onUpdateDeleteMessages = (update: Update.updateDeleteMessages | Update.updateDeleteChannelMessages) => { |
|
|
|
case 'updateDeleteChannelMessages': { |
|
|
|
|
|
|
|
const channelId: number = (update as Update.updateDeleteChannelMessages).channel_id; |
|
|
|
const channelId: number = (update as Update.updateDeleteChannelMessages).channel_id; |
|
|
|
//const messages = (update as any as Update.updateDeleteChannelMessages).messages;
|
|
|
|
//const messages = (update as any as Update.updateDeleteChannelMessages).messages;
|
|
|
|
const messages = (update as any as Update.updateDeleteChannelMessages).messages.map(id => this.generateMessageId(id)); |
|
|
|
const messages = (update as any as Update.updateDeleteChannelMessages).messages.map(id => this.generateMessageId(id)); |
|
|
|
const peerId: number = channelId ? -channelId : this.getMessageById(messages[0]).peerId; |
|
|
|
const peerId: number = channelId ? -channelId : this.getMessageById(messages[0]).peerId; |
|
|
|
|
|
|
|
|
|
|
|
if(!peerId) { |
|
|
|
if(!peerId) { |
|
|
|
break; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
apiManager.clearCache('messages.getSearchCounters', (params) => { |
|
|
|
apiManager.clearCache('messages.getSearchCounters', (params) => { |
|
|
@ -4515,10 +4536,9 @@ export class AppMessagesManager { |
|
|
|
this.reloadConversation(peerId); |
|
|
|
this.reloadConversation(peerId); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateChannel': { |
|
|
|
private onUpdateChannel = (update: Update.updateChannel) => { |
|
|
|
const channelId: number = update.channel_id; |
|
|
|
const channelId: number = update.channel_id; |
|
|
|
const peerId = -channelId; |
|
|
|
const peerId = -channelId; |
|
|
|
const channel = appChatsManager.getChat(channelId); |
|
|
|
const channel = appChatsManager.getChat(channelId); |
|
|
@ -4545,12 +4565,9 @@ export class AppMessagesManager { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
private onUpdateChannelReload = (update: any) => { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
case 'updateChannelReload': { |
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
const channelId: number = update.channel_id; |
|
|
|
const channelId: number = update.channel_id; |
|
|
|
const peerId = -channelId; |
|
|
|
const peerId = -channelId; |
|
|
@ -4561,11 +4578,9 @@ export class AppMessagesManager { |
|
|
|
this.reloadConversation(-channelId).then(() => { |
|
|
|
this.reloadConversation(-channelId).then(() => { |
|
|
|
rootScope.broadcast('history_reload', peerId); |
|
|
|
rootScope.broadcast('history_reload', peerId); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
private onUpdateChannelMessageViews = (update: Update.updateChannelMessageViews) => { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateChannelMessageViews': { |
|
|
|
|
|
|
|
const views = update.views; |
|
|
|
const views = update.views; |
|
|
|
//const mid = update.id;
|
|
|
|
//const mid = update.id;
|
|
|
|
const mid = this.generateMessageId(update.id); |
|
|
|
const mid = this.generateMessageId(update.id); |
|
|
@ -4574,10 +4589,9 @@ export class AppMessagesManager { |
|
|
|
message.views = views; |
|
|
|
message.views = views; |
|
|
|
rootScope.broadcast('message_views', {mid, views}); |
|
|
|
rootScope.broadcast('message_views', {mid, views}); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateServiceNotification': { |
|
|
|
private onUpdateServiceNotification = (update: Update.updateServiceNotification) => { |
|
|
|
//this.log('updateServiceNotification', update);
|
|
|
|
//this.log('updateServiceNotification', update);
|
|
|
|
const fromId = 777000; |
|
|
|
const fromId = 777000; |
|
|
|
const peerId = fromId; |
|
|
|
const peerId = fromId; |
|
|
@ -4607,17 +4621,14 @@ export class AppMessagesManager { |
|
|
|
|
|
|
|
|
|
|
|
if(update.inbox_date) { |
|
|
|
if(update.inbox_date) { |
|
|
|
this.pendingTopMsgs[peerId] = messageId; |
|
|
|
this.pendingTopMsgs[peerId] = messageId; |
|
|
|
this.handleUpdate({ |
|
|
|
this.onUpdateNewMessage({ |
|
|
|
_: 'updateNewMessage', |
|
|
|
_: 'updateNewMessage', |
|
|
|
message |
|
|
|
message |
|
|
|
} as any); |
|
|
|
} as any); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
private onUpdatePinnedMessages = (update: Update.updatePinnedMessages | Update.updatePinnedChannelMessages) => { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updatePinnedMessages': |
|
|
|
|
|
|
|
case 'updatePinnedChannelMessages': { |
|
|
|
|
|
|
|
const channelId = update._ === 'updatePinnedChannelMessages' ? update.channel_id : undefined; |
|
|
|
const channelId = update._ === 'updatePinnedChannelMessages' ? update.channel_id : undefined; |
|
|
|
const peerId = channelId ? -channelId : appPeersManager.getPeerId((update as Update.updatePinnedMessages).peer); |
|
|
|
const peerId = channelId ? -channelId : appPeersManager.getPeerId((update as Update.updatePinnedMessages).peer); |
|
|
|
|
|
|
|
|
|
|
@ -4670,11 +4681,9 @@ export class AppMessagesManager { |
|
|
|
rootScope.broadcast('peer_pinned_messages', {peerId, mids: messages, pinned: werePinned}); |
|
|
|
rootScope.broadcast('peer_pinned_messages', {peerId, mids: messages, pinned: werePinned}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
private onUpdateNotifySettings = (update: Update.updateNotifySettings) => { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateNotifySettings': { |
|
|
|
|
|
|
|
const {peer, notify_settings} = update; |
|
|
|
const {peer, notify_settings} = update; |
|
|
|
if(peer._ === 'notifyPeer') { |
|
|
|
if(peer._ === 'notifyPeer') { |
|
|
|
const peerId = appPeersManager.getPeerId((peer as NotifyPeer.notifyPeer).peer); |
|
|
|
const peerId = appPeersManager.getPeerId((peer as NotifyPeer.notifyPeer).peer); |
|
|
@ -4685,12 +4694,9 @@ export class AppMessagesManager { |
|
|
|
rootScope.broadcast('dialog_notify_settings', dialog); |
|
|
|
rootScope.broadcast('dialog_notify_settings', dialog); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/////this.log('updateNotifySettings', peerId, notify_settings);
|
|
|
|
private onUpdateNewScheduledMessage = (update: Update.updateNewScheduledMessage) => { |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateNewScheduledMessage': { |
|
|
|
|
|
|
|
const message = update.message as MyMessage; |
|
|
|
const message = update.message as MyMessage; |
|
|
|
const peerId = this.getMessagePeer(message); |
|
|
|
const peerId = this.getMessagePeer(message); |
|
|
|
|
|
|
|
|
|
|
@ -4712,11 +4718,9 @@ export class AppMessagesManager { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
private onUpdateDeleteScheduledMessages = (update: Update.updateDeleteScheduledMessages) => { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'updateDeleteScheduledMessages': { |
|
|
|
|
|
|
|
const peerId = appPeersManager.getPeerId(update.peer); |
|
|
|
const peerId = appPeersManager.getPeerId(update.peer); |
|
|
|
|
|
|
|
|
|
|
|
const storage = this.scheduledMessagesStorage[peerId]; |
|
|
|
const storage = this.scheduledMessagesStorage[peerId]; |
|
|
@ -4726,11 +4730,7 @@ export class AppMessagesManager { |
|
|
|
|
|
|
|
|
|
|
|
rootScope.broadcast('scheduled_delete', {peerId, mids}); |
|
|
|
rootScope.broadcast('scheduled_delete', {peerId, mids}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private updateMessageRepliesIfNeeded(threadMessage: MyMessage) { |
|
|
|
private updateMessageRepliesIfNeeded(threadMessage: MyMessage) { |
|
|
|
try { // * на всякий случай, скорее всего это не понадобится
|
|
|
|
try { // * на всякий случай, скорее всего это не понадобится
|
|
|
|