From 42285dde02bc1c4a684dde5203f379291e1c5741 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Sun, 26 Jun 2022 18:38:54 +0200 Subject: [PATCH] Some fixes --- src/components/chat/topbar.ts | 39 +++++------------------- src/lib/appManagers/appDialogsManager.ts | 5 +-- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/components/chat/topbar.ts b/src/components/chat/topbar.ts index 43b3364a..8c34ff50 100644 --- a/src/components/chat/topbar.ts +++ b/src/components/chat/topbar.ts @@ -781,41 +781,18 @@ export default class ChatTopbar { }); } } else if(this.chat.type === 'scheduled') { - if(peerId === rootScope.myId) { - //title = [count > 1 ? count : false, 'Reminders'].filter(Boolean).join(' '); - titleEl = i18n('Reminders'); - } else { - titleEl = i18n('ScheduledMessages'); - //title = [count > 1 ? count : false, 'Scheduled Messages'].filter(Boolean).join(' '); - } - + titleEl = i18n(peerId === rootScope.myId ? 'Reminders' : 'ScheduledMessages'); + } else if(this.chat.type === 'discussion') { if(count === undefined) { - this.managers.appMessagesManager.getScheduledMessages(peerId).then((mids) => { - if(!middleware()) return; - this.setTitle(mids.length); - }); + const result = await this.managers.acknowledged.appMessagesManager.getHistory(peerId, 0, 1, 0, this.chat.threadId); + if(result.cached) { + const historyResult = await result.result; + count = historyResult.count; + } else result.result.then((historyResult) => this.setTitle(historyResult.count)); } - } else if(this.chat.type === 'discussion') { + if(count === undefined) titleEl = i18n('Loading'); else titleEl = i18n('Chat.Title.Comments', [count]); - - if(count === undefined) { - Promise.all([ - this.managers.appMessagesManager.getHistory(peerId, 0, 1, 0, this.chat.threadId), - Promise.resolve() - ]).then(([historyResult]) => { - if(!middleware()) return; - const count = historyResult?.count; - if(typeof(count) !== 'number') { - setTimeout(() => { - if(!middleware()) return; - this.setTitle(); - }, 30); - } else { - this.setTitle(count); - } - }); - } } else if(this.chat.type === 'chat') { [titleEl, icons] = await Promise.all([ wrapPeerTitle({ diff --git a/src/lib/appManagers/appDialogsManager.ts b/src/lib/appManagers/appDialogsManager.ts index 8ed37adf..199b8528 100644 --- a/src/lib/appManagers/appDialogsManager.ts +++ b/src/lib/appManagers/appDialogsManager.ts @@ -1495,8 +1495,10 @@ export class AppDialogsManager { return; } + const peerId = elem.dataset.peerId.toPeerId(); + if(e.ctrlKey || e.metaKey) { - window.open((elem as HTMLAnchorElement).href, '_blank'); + window.open((elem as HTMLAnchorElement).href || ('#' + peerId), '_blank'); cancelEvent(e); return; } @@ -1517,7 +1519,6 @@ export class AppDialogsManager { if(elem) { if(onFound) onFound(); - const peerId = elem.dataset.peerId.toPeerId(); const lastMsgId = +elem.dataset.mid || undefined; setPeerFunc({