Changes to page loading
Chat message pages now use passphrases from the stored model.
This commit is contained in:
parent
78ed6430da
commit
ff43977f93
@ -37,6 +37,7 @@ const encryptionService = EncryptionServiceFactory.getEncryptionService();
|
|||||||
|
|
||||||
const chatModelHelper = new ChatModelHelper(encryptionService, ns);
|
const chatModelHelper = new ChatModelHelper(encryptionService, ns);
|
||||||
const chatModel = new ChatModel(chatModelHelper);
|
const chatModel = new ChatModel(chatModelHelper);
|
||||||
|
const userModel = new UserModel(ns);
|
||||||
const cvDeps: ChatViewDeps = {
|
const cvDeps: ChatViewDeps = {
|
||||||
chatModel: chatModel,
|
chatModel: chatModel,
|
||||||
// @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
|
// @ts-ignore: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'. Type 'null' is not assignable to type 'HTMLElement'.
|
||||||
@ -45,7 +46,8 @@ const cvDeps: ChatViewDeps = {
|
|||||||
messageReceiveTemplate: TemplateFactory.getTemplate('msg_container_template'),
|
messageReceiveTemplate: TemplateFactory.getTemplate('msg_container_template'),
|
||||||
markdownService: new MarkDownItMarkDownService,
|
markdownService: new MarkDownItMarkDownService,
|
||||||
encryptionService: encryptionService,
|
encryptionService: encryptionService,
|
||||||
notificationService: ns
|
notificationService: ns,
|
||||||
|
userModel: userModel
|
||||||
}
|
}
|
||||||
const chatView = new ChatView(cvDeps);
|
const chatView = new ChatView(cvDeps);
|
||||||
chatModel.attach(chatView);
|
chatModel.attach(chatView);
|
||||||
@ -53,7 +55,7 @@ const chatController = new ChatController(chatModel, chatView);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const userModel = new UserModel(ns);
|
|
||||||
const uvDeps: UserViewDeps = {
|
const uvDeps: UserViewDeps = {
|
||||||
model: userModel,
|
model: userModel,
|
||||||
chatModel: chatModel,
|
chatModel: chatModel,
|
||||||
|
@ -12,6 +12,7 @@ import { ChatViewDeps } from "./ChatViewDeps";
|
|||||||
import { fetchHandler } from "./FetchHandler";
|
import { fetchHandler } from "./FetchHandler";
|
||||||
import { ObserverData } from '../observe/ObserverData';
|
import { ObserverData } from '../observe/ObserverData';
|
||||||
import { NotificationService } from '../service/NotificationService';
|
import { NotificationService } from '../service/NotificationService';
|
||||||
|
import { UserModel } from '../model/UserModel';
|
||||||
|
|
||||||
export class ChatView implements Observer<ChatMessageViewModel> {
|
export class ChatView implements Observer<ChatMessageViewModel> {
|
||||||
private readonly _chatModel: ChatModel;
|
private readonly _chatModel: ChatModel;
|
||||||
@ -21,6 +22,7 @@ export class ChatView implements Observer<ChatMessageViewModel> {
|
|||||||
private readonly _markdownService: MarkDownService;
|
private readonly _markdownService: MarkDownService;
|
||||||
private readonly _encryptionService: EncryptionService;
|
private readonly _encryptionService: EncryptionService;
|
||||||
private readonly _notificationService: NotificationService;
|
private readonly _notificationService: NotificationService;
|
||||||
|
private readonly _userModel: UserModel;
|
||||||
|
|
||||||
|
|
||||||
constructor(deps: ChatViewDeps) {
|
constructor(deps: ChatViewDeps) {
|
||||||
@ -31,6 +33,7 @@ export class ChatView implements Observer<ChatMessageViewModel> {
|
|||||||
this._markdownService = deps.markdownService;
|
this._markdownService = deps.markdownService;
|
||||||
this._encryptionService = deps.encryptionService;
|
this._encryptionService = deps.encryptionService;
|
||||||
this._notificationService = deps.notificationService;
|
this._notificationService = deps.notificationService;
|
||||||
|
this._userModel = deps.userModel;
|
||||||
this._initEventListeners();
|
this._initEventListeners();
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
@ -196,22 +199,9 @@ export class ChatView implements Observer<ChatMessageViewModel> {
|
|||||||
if ($(this._messageContainer).scrollTop() == 0 && $(this._messageContainer).html() != "") {
|
if ($(this._messageContainer).scrollTop() == 0 && $(this._messageContainer).html() != "") {
|
||||||
let currentMsg = $('.msg:first');
|
let currentMsg = $('.msg:first');
|
||||||
log.debug('Reached top')
|
log.debug('Reached top')
|
||||||
let passphrase: string;
|
let ab = this._userModel.activeUsersList.find(u => u.userName == JsonAPI.contactName)
|
||||||
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;
|
|
||||||
}
|
|
||||||
if (JsonAPI.contactName != null)
|
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) {
|
if (currentMsg != null) {
|
||||||
// log.debug(currentMsg.offset()!.top)
|
// log.debug(currentMsg.offset()!.top)
|
||||||
$(this._messageContainer).scrollTop(currentMsg.position().top - $('.msg').position()!.top)
|
$(this._messageContainer).scrollTop(currentMsg.position().top - $('.msg').position()!.top)
|
||||||
|
@ -3,6 +3,7 @@ import { ChatModel } from "../model/ChatModel";
|
|||||||
import { MarkDownService } from "../service/MarkDownService";
|
import { MarkDownService } from "../service/MarkDownService";
|
||||||
import { EncryptionService } from "../service/EncryptionService";
|
import { EncryptionService } from "../service/EncryptionService";
|
||||||
import { NotificationService } from "../service/NotificationService";
|
import { NotificationService } from "../service/NotificationService";
|
||||||
|
import { UserModel } from "../model/UserModel";
|
||||||
|
|
||||||
export interface ChatViewDeps {
|
export interface ChatViewDeps {
|
||||||
chatModel: ChatModel;
|
chatModel: ChatModel;
|
||||||
@ -11,5 +12,6 @@ export interface ChatViewDeps {
|
|||||||
messageReceiveTemplate: Handlebars.TemplateDelegate<ChatMessageViewModel>;
|
messageReceiveTemplate: Handlebars.TemplateDelegate<ChatMessageViewModel>;
|
||||||
markdownService: MarkDownService;
|
markdownService: MarkDownService;
|
||||||
encryptionService: EncryptionService;
|
encryptionService: EncryptionService;
|
||||||
notificationService: NotificationService
|
notificationService: NotificationService;
|
||||||
|
userModel: UserModel
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user