@ -4,8 +4,6 @@
@@ -4,8 +4,6 @@
* https : //github.com/morethanwords/tweb/blob/master/LICENSE
* /
import type { AppMessagesManager } from "../../lib/appManagers/appMessagesManager" ;
import type { AppPeersManager } from "../../lib/appManagers/appPeersManager" ;
import type ChatTopbar from "./topbar" ;
import PopupPinMessage from "../popups/unpinMessage" ;
import PinnedContainer from "./pinnedContainer" ;
@ -24,6 +22,7 @@ import debounce from "../../helpers/schedulers/debounce";
@@ -24,6 +22,7 @@ import debounce from "../../helpers/schedulers/debounce";
import throttle from "../../helpers/schedulers/throttle" ;
import { AppManagers } from "../../lib/appManagers/managers" ;
import { Message } from "../../layer" ;
import { logger } from "../../lib/logger" ;
class AnimatedSuper {
static DURATION = 200 ;
@ -253,14 +252,19 @@ export default class ChatPinnedMessage {
@@ -253,14 +252,19 @@ export default class ChatPinnedMessage {
private setPinnedMessage : ( ) = > void ;
private isStatic = false ;
private isStatic : boolean ;
private debug = false ;
private debug : boolean ;
public setCorrectIndexThrottled : ( lastScrollDirection? : number ) = > void ;
private log : ReturnType < typeof logger > ;
constructor ( private topbar : ChatTopbar , private chat : Chat , private managers : AppManagers ) {
this . listenerSetter = new ListenerSetter ( ) ;
this . log = logger ( 'PM' ) ;
this . debug = true ;
this . isStatic = false ;
const dAC = new ReplyContainer ( 'pinned-message' ) ;
this . pinnedMessageContainer = new PinnedContainer ( {
@ -361,14 +365,14 @@ export default class ChatPinnedMessage {
@@ -361,14 +365,14 @@ export default class ChatPinnedMessage {
//const perf = performance.now();
let el = this . chat . bubbles . getBubbleByPoint ( 'bottom' ) ;
//this.chat. log('[PM]: setCorrectIndex: get last element perf:', performance.now() - perf, el);
//this.log('setCorrectIndex: get last element perf:', performance.now() - perf, el);
if ( ! el ) return ;
//return;
const mid = el . dataset . mid ;
if ( el && mid !== undefined ) {
//this.chat. log('[PM]: setCorrectIndex will test mid:', mid);
//this.log('setCorrectIndex will test mid:', mid);
this . testMid ( + mid , lastScrollDirection ) ;
}
}
@ -379,7 +383,7 @@ export default class ChatPinnedMessage {
@@ -379,7 +383,7 @@ export default class ChatPinnedMessage {
//if(lastScrollDirection !== undefined) return;
if ( this . hidden ) return ;
//this.chat. log('[PM]: testMid', mid);
//this.log('testMid', mid);
let currentIndex : number = this . mids . findIndex ( ( _mid ) = > _mid <= mid ) ;
if ( currentIndex !== - 1 && ! this . isNeededMore ( currentIndex ) ) {
@ -401,7 +405,7 @@ export default class ChatPinnedMessage {
@@ -401,7 +405,7 @@ export default class ChatPinnedMessage {
currentIndex = 0 ;
} * /
//this.chat. log('[PM]: testMid: pinned currentIndex', currentIndex, mid);
//this.log('testMid: pinned currentIndex', currentIndex, mid);
const changed = this . pinnedIndex !== currentIndex ;
if ( changed ) {
@ -431,6 +435,9 @@ export default class ChatPinnedMessage {
@@ -431,6 +435,9 @@ export default class ChatPinnedMessage {
this . loading = true ;
try {
const log = this . debug ? this . log . bindPrefix ( 'getCurrentIndex' ) : undefined ;
log && log ( 'start' , mid , correctAfter ) ;
let gotRest = false ;
const promises = [
this . managers . appMessagesManager . getSearch ( {
@ -484,9 +491,9 @@ export default class ChatPinnedMessage {
@@ -484,9 +491,9 @@ export default class ChatPinnedMessage {
this . loadedTop = ( this . offsetIndex + this . mids . length ) === this . count ;
this . loadedBottom = ! this . offsetIndex ;
this . debu g && this . chat . log ( '[PM]: getCurrentIndex result: ' , mid , result , backLimited , this . offsetIndex , this . loadedTop , this . loadedBottom ) ;
lo g && log ( 'result' , mid , result , backLimited , this . offsetIndex , this . loadedTop , this . loadedBottom ) ;
} catch ( err ) {
this . chat . log . error ( '[PM]: getCurrentIndex error' , err ) ;
this . log . error ( 'getCurrentIndex error' , err ) ;
}
this . loading = false ;
@ -528,7 +535,7 @@ export default class ChatPinnedMessage {
@@ -528,7 +535,7 @@ export default class ChatPinnedMessage {
public async handleFollowingPinnedMessage() {
this . locked = true ;
this . debug && this . chat . log ( '[PM]: handleFollowingPinnedMessage' ) ;
this . debug && this . log ( 'handleFollowingPinnedMessage' ) ;
try {
this . setScrollDownListener ( ) ;
@ -544,16 +551,16 @@ export default class ChatPinnedMessage {
@@ -544,16 +551,16 @@ export default class ChatPinnedMessage {
await this . getCurrentIndexPromise ;
}
this . debug && this . chat . log ( '[PM]: handleFollowingPinnedMessage: unlock' ) ;
this . debug && this . log ( 'handleFollowingPinnedMessage: unlock' ) ;
this . locked = false ;
/* / / п о д о ж д ё м , п о к а с к р о л л о с т а н о в и т с я
setTimeout ( ( ) = > {
this . chat . log ( '[PM]: handleFollowingPinnedMessage: unlock' ) ;
this . log ( 'handleFollowingPinnedMessage: unlock' ) ;
this . locked = false ;
} , 50 ) ; * /
} catch ( err ) {
this . chat . log . error ( '[PM]: handleFollowingPinnedMessage error:' , err ) ;
this . log . error ( 'handleFollowingPinnedMessage error:' , err ) ;
this . locked = false ;
this . waitForScrollBottom = false ;
@ -603,7 +610,7 @@ export default class ChatPinnedMessage {
@@ -603,7 +610,7 @@ export default class ChatPinnedMessage {
const fromTop = pinnedIndex > this . wasPinnedIndex ;
this . debug && this . chat . log ( '[PM]: setPinnedMessage: fromTop' , fromTop , pinnedIndex , this . wasPinnedIndex ) ;
this . debug && this . log ( 'setPinnedMessage: fromTop' , fromTop , pinnedIndex , this . wasPinnedIndex ) ;
const writeTo = this . animatedSubtitle . getRow ( pinnedIndex ) ;
const writeMediaTo = this . animatedMedia . getRow ( pinnedIndex ) ;