Organized imports
This commit is contained in:
parent
2b3d6009f1
commit
00a01bc81b
@ -1,26 +1,26 @@
|
||||
import { Client } from "@stomp/stompjs";
|
||||
import { Builder } from "builder-pattern";
|
||||
import * as Handlebars from "handlebars";
|
||||
import * as log from "loglevel";
|
||||
import { ChatController } from "./controller/ChatController";
|
||||
import { UserController } from "./controller/UserController";
|
||||
import { ChatModel } from "./model/ChatModel";
|
||||
import { ChatModelHelper } from "./model/ChatModelHelper";
|
||||
import { UserModel } from "./model/UserModel";
|
||||
import log from "loglevel";
|
||||
import moment from "moment";
|
||||
import SockJS from "sockjs-client";
|
||||
import { AlertifyNotificationService } from "../common/service/AlertifyNotificationService";
|
||||
import { EncryptionServiceFactory } from "../common/service/EncryptionServiceFactory";
|
||||
import { FuseSearchService } from "../common/service/FuseSearchService";
|
||||
import { MarkDownItMarkDownService } from "../common/service/MarkDownItMarkDownService";
|
||||
import { NotificationService } from "../common/service/NotificationService";
|
||||
import { SearchService } from "../common/service/SearchService";
|
||||
import { ChatController } from "./controller/ChatController";
|
||||
import { UserController } from "./controller/UserController";
|
||||
import { ChatModel } from "./model/ChatModel";
|
||||
import { ChatModelHelper } from "./model/ChatModelHelper";
|
||||
import { UserModel } from "./model/UserModel";
|
||||
import { TemplateFactory } from "./template/TemplateFactory";
|
||||
import { ChatView } from "./view/ChatView";
|
||||
import { ChatViewDeps } from "./view/ChatViewDeps";
|
||||
import { UserView } from "./view/UserView";
|
||||
import { UserViewDeps } from "./view/UserViewDeps";
|
||||
import { ActiveUserViewModel } from "./viewmodel/ActiveUserViewModel";
|
||||
import moment = require("moment");
|
||||
import SockJS from "sockjs-client";
|
||||
import { Client } from "@stomp/stompjs";
|
||||
|
||||
// log.setLevel("TRACE");
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { Subject } from "../observe/Observable";
|
||||
import { Observer } from "../observe/Observer";
|
||||
import { ObserverData } from "../observe/ObserverData";
|
||||
import { JsonAPI } from "../singleton/JsonAPI";
|
||||
import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel";
|
||||
import { ChatMessageViewModel } from "../viewmodel/ChatMessageViewModel";
|
||||
import { ChatModelHelper } from "./ChatModelHelper";
|
||||
import log = require("loglevel");
|
||||
import { ObserverData } from "../observe/ObserverData";
|
||||
import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel";
|
||||
import moment = require("moment");
|
||||
import log from "loglevel";
|
||||
import moment from "moment";
|
||||
|
||||
interface Params {
|
||||
userName: string;
|
||||
|
@ -1,9 +1,9 @@
|
||||
import * as log from "loglevel";
|
||||
import log from "loglevel";
|
||||
import { ChatMessageDTO } from "../../common/dto/ChatMessageDTO";
|
||||
import { Sprintf } from "../../common/global/Sprintf";
|
||||
import { EncryptionService } from "../../common/service/EncryptionService";
|
||||
import { NotificationService } from "../../common/service/NotificationService";
|
||||
import { JsonAPI } from "../singleton/JsonAPI";
|
||||
import { Sprintf } from "../../common/global/Sprintf";
|
||||
import { ChatMessageViewModel } from "../viewmodel/ChatMessageViewModel";
|
||||
import { fetchErrorHandler } from "./FetchErrorHandler";
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
import * as log from "loglevel";
|
||||
import log from "loglevel";
|
||||
import { NotificationService } from "../../common/service/NotificationService";
|
||||
import { Subject } from "../observe/Observable";
|
||||
import { Observer } from "../observe/Observer";
|
||||
import { JsonAPI } from "../singleton/JsonAPI";
|
||||
import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel";
|
||||
import { fetchErrorHandler } from "./FetchErrorHandler";
|
||||
import { NotificationService } from "../../common/service/NotificationService";
|
||||
|
||||
export class UserModel implements Subject<ActiveUserViewModel> {
|
||||
/**
|
||||
@ -64,8 +64,8 @@ export class UserModel implements Subject<ActiveUserViewModel> {
|
||||
|
||||
updateLastActive(username: String, lastActive: Date): void {
|
||||
this._activeUsersList
|
||||
.filter(u => u.userName == username)
|
||||
.forEach(u => u.lastActive = lastActive)
|
||||
.filter((u) => u.userName == username)
|
||||
.forEach((u) => (u.lastActive = lastActive));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,18 +1,18 @@
|
||||
import * as DOMPurify from "dompurify";
|
||||
import * as log from "loglevel";
|
||||
import DOMPurify from "dompurify";
|
||||
import log from "loglevel";
|
||||
import { ChatMessageDTO } from "../../common/dto/ChatMessageDTO";
|
||||
import { MessageCipherDTO } from "../../common/dto/MessageCipherDTO";
|
||||
import { ChatModel } from "../model/ChatModel";
|
||||
import { Observer } from "../observe/Observer";
|
||||
import { EncryptionService } from "../../common/service/EncryptionService";
|
||||
import { MarkDownService } from "../../common/service/MarkDownService";
|
||||
import { NotificationService } from "../../common/service/NotificationService";
|
||||
import { ChatModel } from "../model/ChatModel";
|
||||
import { UserModel } from "../model/UserModel";
|
||||
import { Observer } from "../observe/Observer";
|
||||
import { ObserverData } from "../observe/ObserverData";
|
||||
import { JsonAPI } from "../singleton/JsonAPI";
|
||||
import { ChatMessageViewModel } from "../viewmodel/ChatMessageViewModel";
|
||||
import { ChatViewDeps } from "./ChatViewDeps";
|
||||
import { fetchHandler } from "./FetchHandler";
|
||||
import { ObserverData } from "../observe/ObserverData";
|
||||
import { NotificationService } from "../../common/service/NotificationService";
|
||||
import { UserModel } from "../model/UserModel";
|
||||
|
||||
export class ChatView implements Observer<ChatMessageViewModel> {
|
||||
private readonly _chatModel: ChatModel;
|
||||
|
@ -1,15 +1,15 @@
|
||||
import { Observer } from "../observe/Observer";
|
||||
import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel";
|
||||
import { ChatModel } from "../model/ChatModel";
|
||||
import log = require("loglevel");
|
||||
import * as DOMPurify from "dompurify";
|
||||
import DOMPurify from "dompurify";
|
||||
import { NotificationService } from "../../common/service/NotificationService";
|
||||
import { SearchService } from "../../common/service/SearchService";
|
||||
import { ChatModel } from "../model/ChatModel";
|
||||
import { UserModel } from "../model/UserModel";
|
||||
import { UserViewDeps } from "./UserViewDeps";
|
||||
import { Observer } from "../observe/Observer";
|
||||
import { ObserverData } from "../observe/ObserverData";
|
||||
import { JsonAPI } from "../singleton/JsonAPI";
|
||||
import { NotificationService } from "../../common/service/NotificationService";
|
||||
import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel";
|
||||
import { ChatMessageViewModel } from "../viewmodel/ChatMessageViewModel";
|
||||
import { UserViewDeps } from "./UserViewDeps";
|
||||
import log from "loglevel";
|
||||
|
||||
export class UserView implements Observer<ActiveUserViewModel> {
|
||||
private readonly _model: UserModel;
|
||||
@ -89,15 +89,18 @@ export class UserView implements Observer<ActiveUserViewModel> {
|
||||
JsonAPI.contactName = userName;
|
||||
// @ts-ignore: Object is possibly 'null'.
|
||||
document.getElementById("user-name-span").innerText = userName;
|
||||
let currentUser = this._model.activeUsersList.find((vm) => vm.userName === userName) || new ActiveUserViewModel();
|
||||
let currentUser =
|
||||
this._model.activeUsersList.find((vm) => vm.userName === userName) ||
|
||||
new ActiveUserViewModel();
|
||||
currentUser.userName = userName;
|
||||
|
||||
if (!currentUser?.passphrase) {
|
||||
this._notificationService.passphrasePrompt(
|
||||
async (result) => {
|
||||
this._notificationService.passphrasePrompt(async (result) => {
|
||||
if (result) {
|
||||
|
||||
const valid = await this._chatModel.isPassphraseValid(result, currentUser.userName!);
|
||||
const valid = await this._chatModel.isPassphraseValid(
|
||||
result,
|
||||
currentUser.userName!
|
||||
);
|
||||
if (!valid) {
|
||||
bootbox.alert("Some error occured. Please check your password");
|
||||
log.error("invalid password");
|
||||
@ -105,7 +108,10 @@ export class UserView implements Observer<ActiveUserViewModel> {
|
||||
}
|
||||
currentUser.unlocked = true;
|
||||
currentUser.passphrase = result;
|
||||
const chatMessages: ChatMessageViewModel[] = await this._chatModel.getMessages(currentUser, "new");
|
||||
const chatMessages: ChatMessageViewModel[] = await this._chatModel.getMessages(
|
||||
currentUser,
|
||||
"new"
|
||||
);
|
||||
|
||||
this._model.activeUsersList
|
||||
.filter((v) => v.userName == currentUser!.userName)
|
||||
@ -120,27 +126,26 @@ export class UserView implements Observer<ActiveUserViewModel> {
|
||||
chatMessages[chatMessages.length - 1].message);
|
||||
if (lastMessageText.length > 15) {
|
||||
v.lastMessageText =
|
||||
chatMessages[chatMessages.length - 1].message.slice(
|
||||
0,
|
||||
15
|
||||
) + "...";
|
||||
chatMessages[chatMessages.length - 1].message.slice(0, 15) +
|
||||
"...";
|
||||
}
|
||||
}
|
||||
});
|
||||
this._promptHandler(currentUser);
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
});
|
||||
} else {
|
||||
this._chatModel.getMessages(currentUser, "new");
|
||||
}
|
||||
|
||||
el.className += " active";
|
||||
if (currentUser.unlocked && currentUser.lastMessageTime) {
|
||||
this._newMessagesLoop = setInterval(
|
||||
this._chatModel.getMessages.bind(this._chatModel, currentUser, "update"),
|
||||
this._chatModel.getMessages.bind(
|
||||
this._chatModel,
|
||||
currentUser,
|
||||
"update"
|
||||
),
|
||||
10_000
|
||||
);
|
||||
this._model.notify();
|
||||
@ -177,9 +182,8 @@ export class UserView implements Observer<ActiveUserViewModel> {
|
||||
let searchResult = this._searchService.search(list, searchTerm);
|
||||
this.update({ data: searchResult, op: "" });
|
||||
log.debug(searchResult);
|
||||
}
|
||||
else {
|
||||
this._notificationService.error("Please enter a name")
|
||||
} else {
|
||||
this._notificationService.error("Please enter a name");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user