Fix editing folders with dead chats in it
Rollback displaying chat where we're kicked
This commit is contained in:
parent
e152ccbafa
commit
3212916518
@ -377,8 +377,12 @@ export default class AppEditFolderTab extends SliderSuperTab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return super.open().then(() => {
|
return super.open().then(() => {
|
||||||
if(this.type === 'edit') this.onEditOpen();
|
if(this.type === 'edit') {
|
||||||
else this.onCreateOpen();
|
this.setFilter(this.originalFilter, true);
|
||||||
|
this.onEditOpen();
|
||||||
|
} else {
|
||||||
|
this.onCreateOpen();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ export class AppChatsManager {
|
|||||||
|
|
||||||
if(chat._ === 'chatForbidden' ||
|
if(chat._ === 'chatForbidden' ||
|
||||||
chat._ === 'channelForbidden' ||
|
chat._ === 'channelForbidden' ||
|
||||||
(chat as any).pFlags.kicked ||
|
// (chat as any).pFlags.kicked ||
|
||||||
(chat.pFlags.left && !(chat as Chat.channel).pFlags.megagroup)) {
|
(chat.pFlags.left && !(chat as Chat.channel).pFlags.megagroup)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -377,7 +377,7 @@ export class AppChatsManager {
|
|||||||
|| chat._ === 'chatForbidden'
|
|| chat._ === 'chatForbidden'
|
||||||
|| chat._ === 'chatEmpty'
|
|| chat._ === 'chatEmpty'
|
||||||
|| (chat as Chat.chat).pFlags.left
|
|| (chat as Chat.chat).pFlags.left
|
||||||
|| (chat as any).pFlags.kicked
|
// || (chat as any).pFlags.kicked
|
||||||
|| (chat as Chat.chat).pFlags.deactivated) {
|
|| (chat as Chat.chat).pFlags.deactivated) {
|
||||||
good = false;
|
good = false;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ export class AppProfileManager {
|
|||||||
const chat = appChatsManager.getChat(id);
|
const chat = appChatsManager.getChat(id);
|
||||||
if(chat &&
|
if(chat &&
|
||||||
chat.pFlags && (
|
chat.pFlags && (
|
||||||
chat.pFlags.kicked ||
|
// chat.pFlags.kicked ||
|
||||||
chat.pFlags.broadcast && !chat.pFlags.creator && !chat.admin_rights
|
chat.pFlags.broadcast && !chat.pFlags.creator && !chat.admin_rights
|
||||||
)) {
|
)) {
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
|
@ -764,9 +764,9 @@ export default class DialogsStorage {
|
|||||||
// ! chatForbidden stays for chat where you're kicked
|
// ! chatForbidden stays for chat where you're kicked
|
||||||
if(
|
if(
|
||||||
chat._ === 'channelForbidden'
|
chat._ === 'channelForbidden'
|
||||||
|| chat._ === 'chatForbidden'
|
// || chat._ === 'chatForbidden'
|
||||||
|| (chat as Chat.chat).pFlags.left
|
|| (chat as Chat.chat).pFlags.left
|
||||||
|| (chat as any).pFlags.kicked
|
// || (chat as any).pFlags.kicked
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { DialogFilter, Update } from "../../layer";
|
import type { DialogFilter, Update } from "../../layer";
|
||||||
import type { Modify } from "../../types";
|
import type { ArgumentTypes, Modify } from "../../types";
|
||||||
import type { AppPeersManager } from "../appManagers/appPeersManager";
|
import type { AppPeersManager } from "../appManagers/appPeersManager";
|
||||||
import type { AppUsersManager } from "../appManagers/appUsersManager";
|
import type { AppUsersManager } from "../appManagers/appUsersManager";
|
||||||
//import type { ApiManagerProxy } from "../mtproto/mtprotoworker";
|
//import type { ApiManagerProxy } from "../mtproto/mtprotoworker";
|
||||||
@ -13,11 +13,12 @@ import type _rootScope from "../rootScope";
|
|||||||
import type {AppMessagesManager, Dialog} from '../appManagers/appMessagesManager';
|
import type {AppMessagesManager, Dialog} from '../appManagers/appMessagesManager';
|
||||||
import type {AppNotificationsManager} from "../appManagers/appNotificationsManager";
|
import type {AppNotificationsManager} from "../appManagers/appNotificationsManager";
|
||||||
import type { ApiUpdatesManager } from "../appManagers/apiUpdatesManager";
|
import type { ApiUpdatesManager } from "../appManagers/apiUpdatesManager";
|
||||||
|
import type { AppStateManager } from "../appManagers/appStateManager";
|
||||||
import apiManager from "../mtproto/mtprotoworker";
|
import apiManager from "../mtproto/mtprotoworker";
|
||||||
import { AppStateManager } from "../appManagers/appStateManager";
|
|
||||||
import forEachReverse from "../../helpers/array/forEachReverse";
|
import forEachReverse from "../../helpers/array/forEachReverse";
|
||||||
import copy from "../../helpers/object/copy";
|
import copy from "../../helpers/object/copy";
|
||||||
import safeReplaceObject from "../../helpers/object/safeReplaceObject";
|
import safeReplaceObject from "../../helpers/object/safeReplaceObject";
|
||||||
|
import findAndSplice from "../../helpers/array/findAndSplice";
|
||||||
|
|
||||||
export type MyDialogFilter = Modify<DialogFilter, {
|
export type MyDialogFilter = Modify<DialogFilter, {
|
||||||
/* pinned_peers: PeerId[],
|
/* pinned_peers: PeerId[],
|
||||||
@ -321,31 +322,80 @@ export default class FiltersStorage {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public reloadMissingPeerIds(filterId: number, type: 'pinned_peers' | 'include_peers' | 'exclude_peers' = 'pinned_peers') {
|
private p(filterId: number, type: ArgumentTypes<FiltersStorage['reloadMissingPeerIds']>[1], missingPeerIds: PeerId[]) {
|
||||||
const promises: Promise<any>[] = [];
|
|
||||||
const filter = this.getFilter(filterId);
|
const filter = this.getFilter(filterId);
|
||||||
const peers = filter && filter[type];
|
const peers = filter && filter[type];
|
||||||
if(peers?.length) {
|
if(!peers?.length) {
|
||||||
const reloadDialogs = peers.filter((inputPeer, idx) => {
|
return;
|
||||||
const peerId = this.appPeersManager.getPeerId(inputPeer);
|
|
||||||
return !this.reloadedPeerIds.has(peerId) && !this.appMessagesManager.getDialogOnly(peerId);
|
|
||||||
});
|
|
||||||
|
|
||||||
if(reloadDialogs.length) {
|
|
||||||
const reloadPromises = reloadDialogs.map(inputPeer => {
|
|
||||||
const peerId = this.appPeersManager.getPeerId(inputPeer);
|
|
||||||
const promise = this.appMessagesManager.reloadConversation(inputPeer);
|
|
||||||
promise.then(() => {
|
|
||||||
this.reloadedPeerIds.add(peerId);
|
|
||||||
});
|
|
||||||
return promise;
|
|
||||||
});
|
|
||||||
const reloadPromise = Promise.all(reloadPromises);
|
|
||||||
promises.push(reloadPromise);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return promises.length ? Promise.all(promises) : undefined;
|
let spliced = false;
|
||||||
|
missingPeerIds.forEach((peerId) => {
|
||||||
|
const inputPeer = findAndSplice(peers, (inputPeer) => this.appPeersManager.getPeerId(inputPeer) === peerId);
|
||||||
|
if(inputPeer) {
|
||||||
|
spliced = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(spliced) {
|
||||||
|
this.onUpdateDialogFilter({
|
||||||
|
_: 'updateDialogFilter',
|
||||||
|
id: filterId,
|
||||||
|
filter
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public reloadMissingPeerIds(filterId: number, type: 'pinned_peers' | 'include_peers' | 'exclude_peers' = 'pinned_peers') {
|
||||||
|
const filter = this.getFilter(filterId);
|
||||||
|
const peers = filter && filter[type];
|
||||||
|
if(!peers?.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const missingPeerIds: PeerId[] = [];
|
||||||
|
const reloadDialogs = peers.filter((inputPeer) => {
|
||||||
|
const peerId = this.appPeersManager.getPeerId(inputPeer);
|
||||||
|
const isAlreadyReloaded = this.reloadedPeerIds.has(peerId);
|
||||||
|
const dialog = this.appMessagesManager.getDialogOnly(peerId);
|
||||||
|
if(isAlreadyReloaded && !dialog) {
|
||||||
|
missingPeerIds.push(peerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
const reload = !isAlreadyReloaded && !dialog;
|
||||||
|
return reload;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(!reloadDialogs.length) {
|
||||||
|
if(missingPeerIds.length) {
|
||||||
|
this.p(filterId, type, missingPeerIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const reloadPromises = reloadDialogs.map((inputPeer) => {
|
||||||
|
const peerId = this.appPeersManager.getPeerId(inputPeer);
|
||||||
|
const promise = this.appMessagesManager.reloadConversation(inputPeer)
|
||||||
|
.then((dialog) => {
|
||||||
|
this.reloadedPeerIds.add(peerId);
|
||||||
|
|
||||||
|
return dialog ? undefined : peerId;
|
||||||
|
});
|
||||||
|
|
||||||
|
return promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
const reloadPromise = Promise.all(reloadPromises).then((missingPeerIds) => {
|
||||||
|
missingPeerIds = missingPeerIds.filter(Boolean);
|
||||||
|
if(!missingPeerIds.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.p(filterId, type, missingPeerIds);
|
||||||
|
});
|
||||||
|
|
||||||
|
return reloadPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getDialogFilters(overwrite = false): Promise<MyDialogFilter[]> {
|
public async getDialogFilters(overwrite = false): Promise<MyDialogFilter[]> {
|
||||||
|
Loading…
Reference in New Issue
Block a user