@ -12,6 +12,7 @@ import { ChatViewDeps } from "./ChatViewDeps";
import { fetchHandler } from "./FetchHandler" ;
import { ObserverData } from '../observe/ObserverData' ;
import { NotificationService } from '../service/NotificationService' ;
import { UserModel } from '../model/UserModel' ;
export class ChatView implements Observer < ChatMessageViewModel > {
private readonly _chatModel : ChatModel ;
@ -21,6 +22,7 @@ export class ChatView implements Observer<ChatMessageViewModel> {
private readonly _markdownService : MarkDownService ;
private readonly _encryptionService : EncryptionService ;
private readonly _notificationService : NotificationService ;
private readonly _userModel : UserModel ;
constructor ( deps : ChatViewDeps ) {
@ -31,6 +33,7 @@ export class ChatView implements Observer<ChatMessageViewModel> {
this . _markdownService = deps . markdownService ;
this . _encryptionService = deps . encryptionService ;
this . _notificationService = deps . notificationService ;
this . _userModel = deps . userModel ;
this . _initEventListeners ( ) ;
$ ( document ) . ready ( function ( ) {
@ -196,22 +199,9 @@ export class ChatView implements Observer<ChatMessageViewModel> {
if ( $ ( this . _messageContainer ) . scrollTop ( ) == 0 && $ ( this . _messageContainer ) . html ( ) != "" ) {
let currentMsg = $ ( '.msg:first' ) ;
log . debug ( 'Reached top' )
let passphrase : string ;
let passphraseInput = document . getElementById ( 'passphrase' ) as HTMLInputElement ;
if ( passphraseInput == null ) {
log . error ( 'passphraseInput element reference is null' ) ;
return ;
}
passphrase = passphraseInput . value
if ( passphrase == '' || passphrase == null ) {
// alert('Please input passphrase')
// alertify.error('Please enter a passphrase');
log . error ( 'passphrase is empty or null' ) ;
return ;
}
let ab = this . _userModel . activeUsersList . find ( u = > u . userName == JsonAPI . contactName )
if ( JsonAPI . contactName != null )
this . _chatModel . getMessages ( JsonAPI . contactName , passphrase , null , "page" ) . then ( ( ) = > {
this . _chatModel . getMessages ( JsonAPI . contactName , ab ! . passphrase , null , "page" ) . then ( ( ) = > {
if ( currentMsg != null ) {
// log.debug(currentMsg.offset()!.top)
$ ( this . _messageContainer ) . scrollTop ( currentMsg . position ( ) . top - $ ( '.msg' ) . position ( ) ! . top )