Fix leaving legacy groups
This commit is contained in:
parent
1ceb45a96e
commit
522cb782ac
@ -23,11 +23,11 @@ export default class PopupDeleteDialog {
|
|||||||
onSelect && onSelect(promise);
|
onSelect && onSelect(promise);
|
||||||
}; */
|
}; */
|
||||||
|
|
||||||
const callbackLeave = (checked: PopupPeerButtonCallbackCheckboxes) => {
|
const callbackLeave = (checked: PopupPeerButtonCallbackCheckboxes, flush = checkboxes && !!checked.size) => {
|
||||||
let promise = appChatsManager.leave(-peerId);
|
let promise = appChatsManager.leave(-peerId);
|
||||||
|
|
||||||
if(checkboxes && checked.size) {
|
if(flush) {
|
||||||
promise = promise.then(() => {
|
promise = promise.finally(() => {
|
||||||
return appMessagesManager.flushHistory(peerId);
|
return appMessagesManager.flushHistory(peerId);
|
||||||
}) as any;
|
}) as any;
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ export default class PopupDeleteDialog {
|
|||||||
buttons = [{
|
buttons = [{
|
||||||
langKey: 'DeleteChatUser',
|
langKey: 'DeleteChatUser',
|
||||||
isDanger: true,
|
isDanger: true,
|
||||||
callback: callbackLeave
|
callback: (checkboxes) => callbackLeave(checkboxes, true)
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2007,7 +2007,7 @@ export class AppMessagesManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.doFlushHistory(peer, just_clear);
|
return this.doFlushHistory(peer, just_clear, revoke);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2021,7 +2021,7 @@ export class AppMessagesManager {
|
|||||||
const maxId = historyResult.history[0] || 0;
|
const maxId = historyResult.history[0] || 0;
|
||||||
return apiManager.invokeApiSingle('channels.deleteHistory', {
|
return apiManager.invokeApiSingle('channels.deleteHistory', {
|
||||||
channel: appChatsManager.getChannelInput(channelId),
|
channel: appChatsManager.getChannelInput(channelId),
|
||||||
max_id: maxId
|
max_id: this.getServerMessageId(maxId)
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
apiUpdatesManager.processLocalUpdate({
|
apiUpdatesManager.processLocalUpdate({
|
||||||
_: 'updateChannelAvailableMessages',
|
_: 'updateChannelAvailableMessages',
|
||||||
@ -2036,12 +2036,22 @@ export class AppMessagesManager {
|
|||||||
return this.doFlushHistory(appPeersManager.getInputPeerById(peerId), justClear, revoke).then(() => {
|
return this.doFlushHistory(appPeersManager.getInputPeerById(peerId), justClear, revoke).then(() => {
|
||||||
delete this.historiesStorage[peerId];
|
delete this.historiesStorage[peerId];
|
||||||
delete this.messagesStorageByPeerId[peerId];
|
delete this.messagesStorageByPeerId[peerId];
|
||||||
|
delete this.scheduledMessagesStorage[peerId];
|
||||||
|
delete this.threadsStorage[peerId];
|
||||||
|
delete this.searchesStorage[peerId];
|
||||||
|
delete this.pinnedMessages[peerId];
|
||||||
|
delete this.pendingAfterMsgs[peerId];
|
||||||
|
delete this.pendingTopMsgs[peerId];
|
||||||
|
delete this.needSingleMessages[peerId];
|
||||||
|
|
||||||
if(justClear) {
|
if(justClear) {
|
||||||
rootScope.dispatchEvent('dialog_flush', {peerId});
|
rootScope.dispatchEvent('dialog_flush', {peerId});
|
||||||
} else {
|
} else {
|
||||||
this.dialogsStorage.dropDialog(peerId);
|
delete this.notificationsToHandle[peerId];
|
||||||
|
delete this.typings[peerId];
|
||||||
|
this.reloadConversationsPeers.delete(peerId);
|
||||||
|
|
||||||
|
this.dialogsStorage.dropDialog(peerId);
|
||||||
rootScope.dispatchEvent('dialog_drop', {peerId});
|
rootScope.dispatchEvent('dialog_drop', {peerId});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -483,6 +483,8 @@ export class AppStateManager extends EventListenerBase<{
|
|||||||
|
|
||||||
if(peerId) {
|
if(peerId) {
|
||||||
this.singlePeerMap.set(type, peerId);
|
this.singlePeerMap.set(type, peerId);
|
||||||
|
} else {
|
||||||
|
this.singlePeerMap.delete(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,11 +360,12 @@ export default class DialogsStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public dropDialog(peerId: number): [Dialog, number] | [] {
|
public dropDialog(peerId: number): [Dialog, number] | [] {
|
||||||
const foundDialog = this.getDialog(peerId);
|
const foundDialog = this.getDialog(peerId, undefined, false);
|
||||||
if(foundDialog[0]) {
|
if(foundDialog[0]) {
|
||||||
this.byFolders[foundDialog[0].folder_id].splice(foundDialog[1], 1);
|
this.byFolders[foundDialog[0].folder_id].splice(foundDialog[1], 1);
|
||||||
delete this.dialogs[peerId];
|
this.pinnedOrders[foundDialog[0].folder_id].findAndSplice(_peerId => peerId === _peerId);
|
||||||
this.dialogsIndex.indexObject(peerId, '');
|
this.dialogsIndex.indexObject(peerId, '');
|
||||||
|
delete this.dialogs[peerId];
|
||||||
|
|
||||||
// clear from state
|
// clear from state
|
||||||
this.appStateManager.keepPeerSingle(0, 'topMessage_' + peerId);
|
this.appStateManager.keepPeerSingle(0, 'topMessage_' + peerId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user