Fix filling missed dialogs in folders
This commit is contained in:
parent
83fe6947f2
commit
1b49a65db0
@ -2153,14 +2153,16 @@ export class AppMessagesManager {
|
|||||||
return apiManager.invokeApiSingle('channels.deleteHistory', {
|
return apiManager.invokeApiSingle('channels.deleteHistory', {
|
||||||
channel: appChatsManager.getChannelInput(channelId),
|
channel: appChatsManager.getChannelInput(channelId),
|
||||||
max_id: appMessagesIdsManager.getServerMessageId(maxId)
|
max_id: appMessagesIdsManager.getServerMessageId(maxId)
|
||||||
}).then(() => {
|
}).then((bool) => {
|
||||||
apiUpdatesManager.processLocalUpdate({
|
if(bool) {
|
||||||
_: 'updateChannelAvailableMessages',
|
apiUpdatesManager.processLocalUpdate({
|
||||||
channel_id: channelId,
|
_: 'updateChannelAvailableMessages',
|
||||||
available_min_id: maxId
|
channel_id: channelId,
|
||||||
});
|
available_min_id: maxId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return bool;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -907,16 +907,9 @@ export default class DialogsStorage {
|
|||||||
promises.push(fillContactsResult.promise);
|
promises.push(fillContactsResult.promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
const filter = this.appMessagesManager.filtersStorage.getFilter(folderId);
|
const reloadMissingDialogsPromise = this.appMessagesManager.filtersStorage.reloadMissingPeerIds(folderId);
|
||||||
const pinnedPeers = filter?.pinned_peers;
|
if(reloadMissingDialogsPromise) {
|
||||||
if(pinnedPeers?.length) {
|
promises.push(reloadMissingDialogsPromise);
|
||||||
const pinnedPeerIds = filter.pinnedPeerIds;
|
|
||||||
const reloadDialogs = pinnedPeers.filter((inputPeer, idx) => !this.getDialogOnly(pinnedPeerIds[idx]));
|
|
||||||
if(reloadDialogs.length) {
|
|
||||||
const reloadPromises = reloadDialogs.map(inputPeer => this.appMessagesManager.reloadConversation(inputPeer));
|
|
||||||
const reloadPromise = Promise.all(reloadPromises);
|
|
||||||
promises.push(reloadPromise);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(promises.length) {
|
if(promises.length) {
|
||||||
|
@ -39,6 +39,7 @@ const START_ORDER_INDEX = 1;
|
|||||||
export default class FiltersStorage {
|
export default class FiltersStorage {
|
||||||
public filters: {[filterId: string]: MyDialogFilter};
|
public filters: {[filterId: string]: MyDialogFilter};
|
||||||
private orderIndex: number;
|
private orderIndex: number;
|
||||||
|
private reloadedPeerIds: Set<PeerId>;
|
||||||
|
|
||||||
constructor(private appMessagesManager: AppMessagesManager,
|
constructor(private appMessagesManager: AppMessagesManager,
|
||||||
private appPeersManager: AppPeersManager,
|
private appPeersManager: AppPeersManager,
|
||||||
@ -96,6 +97,7 @@ export default class FiltersStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.orderIndex = START_ORDER_INDEX;
|
this.orderIndex = START_ORDER_INDEX;
|
||||||
|
this.reloadedPeerIds = new Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
private onUpdateDialogFilter = (update: Update.updateDialogFilter) => {
|
private onUpdateDialogFilter = (update: Update.updateDialogFilter) => {
|
||||||
@ -298,6 +300,33 @@ export default class FiltersStorage {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public reloadMissingPeerIds(filterId: number) {
|
||||||
|
const promises: Promise<any>[] = [];
|
||||||
|
const filter = this.getFilter(filterId);
|
||||||
|
const pinnedPeers = filter?.pinned_peers;
|
||||||
|
if(pinnedPeers?.length) {
|
||||||
|
const reloadDialogs = pinnedPeers.filter((inputPeer, idx) => {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
public async getDialogFilters(overwrite = false): Promise<MyDialogFilter[]> {
|
public async getDialogFilters(overwrite = false): Promise<MyDialogFilter[]> {
|
||||||
const keys = Object.keys(this.filters);
|
const keys = Object.keys(this.filters);
|
||||||
if(keys.length && !overwrite) {
|
if(keys.length && !overwrite) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user