Browse Source

Fix archived count

Load all archived dialogs to show archived count
master
morethanwords 4 years ago
parent
commit
73bbe33148
  1. 1
      src/components/sidebarLeft/index.ts
  2. 27
      src/lib/appManagers/appDialogsManager.ts
  3. 4
      src/lib/appManagers/appMessagesManager.ts

1
src/components/sidebarLeft/index.ts

@ -322,6 +322,7 @@ export class AppSidebarLeft extends SidebarSlider {
$rootScope.$on('dialogs_archived_unread', (e) => { $rootScope.$on('dialogs_archived_unread', (e) => {
this.archivedCount.innerText = '' + formatNumber(e.detail.count, 1); this.archivedCount.innerText = '' + formatNumber(e.detail.count, 1);
this.archivedCount.classList.toggle('hide', !e.detail.count);
}); });
appUsersManager.getTopPeers(); appUsersManager.getTopPeers();

27
src/lib/appManagers/appDialogsManager.ts

@ -1,3 +1,4 @@
import { ResolutionUnitSpecifier } from "fast-png";
import AvatarElement from "../../components/avatar"; import AvatarElement from "../../components/avatar";
import DialogsContextMenu from "../../components/dialogsContextMenu"; import DialogsContextMenu from "../../components/dialogsContextMenu";
import { horizontalMenu } from "../../components/horizontalMenu"; import { horizontalMenu } from "../../components/horizontalMenu";
@ -336,11 +337,14 @@ export class AppDialogsManager {
this.addFilter(filters[filterID]); this.addFilter(filters[filterID]);
} }
return this.loadDialogs(this.filterID); return this.loadDialogs();
}).then(result => { }).then(result => {
//this.setPinnedDelimiter(); //this.setPinnedDelimiter();
//appSidebarLeft.onChatsScroll(); //appSidebarLeft.onChatsScroll();
this.loadDialogs(1); //this.loadDialogs(1);
appMessagesManager.getConversationsAll('', 1).then(() => {
this.accumulateArchivedUnread();
});
}); });
} }
@ -363,8 +367,9 @@ export class AppDialogsManager {
this.doms = {}; this.doms = {};
this.loadedAll = false; this.loadedAll = false;
this.lastActiveListElement = null; this.lastActiveListElement = null;
this.loadDialogsPromise = undefined;
this.chatList = this.chatLists[this.filterID]; this.chatList = this.chatLists[this.filterID];
this.loadDialogs(this.filterID); this.loadDialogs();
}; };
public setFilterUnreadCount(filterID: number, folder?: Dialog[]) { public setFilterUnreadCount(filterID: number, folder?: Dialog[]) {
@ -460,7 +465,7 @@ export class AppDialogsManager {
}; };
} }
public async loadDialogs(folderID: number) { public async loadDialogs() {
if(testScroll) { if(testScroll) {
return; return;
} }
@ -474,7 +479,9 @@ export class AppDialogsManager {
//return; //return;
const storage = appMessagesManager.dialogsStorage.getFolder(folderID); const filterID = this.filterID;
const storage = appMessagesManager.dialogsStorage.getFolder(filterID);
let offsetIndex = 0; let offsetIndex = 0;
for(let i = storage.length - 1; i >= 0; --i) { for(let i = storage.length - 1; i >= 0; --i) {
@ -492,17 +499,21 @@ export class AppDialogsManager {
const loadCount = 50/*this.chatsLoadCount */; const loadCount = 50/*this.chatsLoadCount */;
const getConversationPromise = (this.filterID > 1 ? appUsersManager.getContacts() as Promise<any> : Promise.resolve()).then(() => { const getConversationPromise = (this.filterID > 1 ? appUsersManager.getContacts() as Promise<any> : Promise.resolve()).then(() => {
return appMessagesManager.getConversations('', offsetIndex, loadCount, folderID); return appMessagesManager.getConversations('', offsetIndex, loadCount, filterID);
}); });
this.loadDialogsPromise = getConversationPromise; this.loadDialogsPromise = getConversationPromise;
const result = await getConversationPromise; const result = await getConversationPromise;
if(this.filterID != filterID) {
return;
}
//console.timeEnd('getDialogs time'); //console.timeEnd('getDialogs time');
if(result && result.dialogs && result.dialogs.length) { if(result && result.dialogs && result.dialogs.length) {
result.dialogs.forEach((dialog: any) => { result.dialogs.forEach((dialog) => {
this.addDialog(dialog); this.addDialog(dialog);
}); });
} }
@ -524,7 +535,7 @@ export class AppDialogsManager {
onChatsScroll = () => { onChatsScroll = () => {
if(this.loadedAll || this.loadDialogsPromise) return; if(this.loadedAll || this.loadDialogsPromise) return;
this.log('onChatsScroll'); this.log('onChatsScroll');
this.loadDialogs(this.filterID); this.loadDialogs();
} }
public setListClickListener(list: HTMLUListElement, onFound?: () => void, withContext = false) { public setListClickListener(list: HTMLUListElement, onFound?: () => void, withContext = false) {

4
src/lib/appManagers/appMessagesManager.ts

@ -1814,9 +1814,9 @@ export class AppMessagesManager {
return false; return false;
} }
public async getConversationsAll(query = '') { public async getConversationsAll(query = '', folderID = 0) {
const limit = 100, outDialogs: Dialog[] = []; const limit = 100, outDialogs: Dialog[] = [];
for(let folderID = 0; folderID < 2; ++folderID) { for(; folderID < 2; ++folderID) {
let offsetIndex = 0; let offsetIndex = 0;
for(;;) { for(;;) {
const {dialogs} = await appMessagesManager.getConversations(query, offsetIndex, limit, folderID); const {dialogs} = await appMessagesManager.getConversations(query, offsetIndex, limit, folderID);

Loading…
Cancel
Save