Refactored model out of chat frntend submodule

This commit is contained in:
Rohan Sircar 2020-06-20 15:35:49 +05:30
parent 6b15e9c9b7
commit 0d78d057bc
17 changed files with 52 additions and 52 deletions

View File

@ -1,4 +1,4 @@
import { Model } from "../model/AbstractModel"; import { Model } from "../../common/model/AbstractModel";
import { View } from "../view/AbstractView"; import { View } from "../view/AbstractView";
// simple restrictions that MVC impose: The Control has a reference to the View and Model + the View has a reference to the Model and the Controller.It also does not have any Observer implementation in the Model, so that the View can update based on it. // simple restrictions that MVC impose: The Control has a reference to the View and Model + the View has a reference to the Model and the Controller.It also does not have any Observer implementation in the Model, so that the View can update based on it.

View File

@ -1,12 +1,12 @@
import { Controller } from "./AbstractController"; import { Controller } from "./AbstractController";
import "../model/AbstractModel" import "../../common/model/AbstractModel"
import "../model/UserModel" import "../../common/model/UserModel"
import "../view/AbstractView" import "../view/AbstractView"
import "../view/UserView" import "../view/UserView"
import { Model } from "../model/AbstractModel"; import { Model } from "../../common/model/AbstractModel";
import { View } from "../view/AbstractView"; import { View } from "../view/AbstractView";
import { ChatMessageViewModel } from "../viewmodel/ChatMessageViewModel"; import { ChatMessageViewModel } from "../viewmodel/ChatMessageViewModel";
import { ChatModel } from "../model/ChatModel"; import { ChatModel } from "../../common/model/ChatModel";
import { ChatView } from "../view/ChatView"; import { ChatView } from "../view/ChatView";
export class ChatController { export class ChatController {

View File

@ -1,13 +1,13 @@
import { Controller } from "./AbstractController"; import { Controller } from "./AbstractController";
import "../model/AbstractModel" import "../../common/model/AbstractModel"
import "../model/UserModel" import "../../common/model/UserModel"
import "../view/AbstractView" import "../view/AbstractView"
import "../view/UserView" import "../view/UserView"
import { Model } from "../model/AbstractModel"; import { Model } from "../../common/model/AbstractModel";
import { View } from "../view/AbstractView"; import { View } from "../view/AbstractView";
import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel"; import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel";
import { UserView } from "../view/UserView"; import { UserView } from "../view/UserView";
import { UserModel } from "../model/UserModel"; import { UserModel } from "../../common/model/UserModel";
export class UserController { export class UserController {
private _model: UserModel; private _model: UserModel;

View File

@ -3,9 +3,9 @@ import * as Handlebars from "handlebars";
import * as log from "loglevel"; import * as log from "loglevel";
import { ChatController } from "./controller/ChatController"; import { ChatController } from "./controller/ChatController";
import { UserController } from "./controller/UserController"; import { UserController } from "./controller/UserController";
import { ChatModel } from "./model/ChatModel"; import { ChatModel } from "../common/model/ChatModel";
import { ChatModelHelper } from "./model/ChatModelHelper"; import { ChatModelHelper } from "../common/model/ChatModelHelper";
import { UserModel } from "./model/UserModel"; import { UserModel } from "../common/model/UserModel";
import { AlertifyNotificationService } from "./service/AlertifyNotificationService"; import { AlertifyNotificationService } from "./service/AlertifyNotificationService";
import { EncryptionServiceFactory } from "./service/EncryptionServiceFactory"; import { EncryptionServiceFactory } from "./service/EncryptionServiceFactory";
import { FuseSearchService } from "./service/FuseSearchService"; import { FuseSearchService } from "./service/FuseSearchService";

View File

@ -1,7 +0,0 @@
import { Subject } from "../observe/Observable";
import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel";
export interface Model extends Subject<any> {
someBusinessMethod(data: Object): void;
}

View File

@ -1,5 +1,5 @@
// simple restrictions that MVC impose: The Control has a reference to the View and Model + the View has a reference to the Model and the Controller.It also does not have any Observer implementation in the Model, so that the View can update based on it. // simple restrictions that MVC impose: The Control has a reference to the View and Model + the View has a reference to the Model and the Controller.It also does not have any Observer implementation in the Model, so that the View can update based on it.
import { Model } from "../model/AbstractModel"; import { Model } from "../../common/model/AbstractModel";
import { Controller } from "../controller/AbstractController"; import { Controller } from "../controller/AbstractController";
import { Observer } from "../observe/Observer"; import { Observer } from "../observe/Observer";
export interface View extends Observer<any> { export interface View extends Observer<any> {

View File

@ -2,7 +2,7 @@ import * as DOMPurify from "dompurify";
import * as log from "loglevel"; import * as log from "loglevel";
import { ChatMessageDTO } from "../dto/ChatMessageDTO"; import { ChatMessageDTO } from "../dto/ChatMessageDTO";
import { MessageCipherDTO } from "../dto/MessageCipherDTO"; import { MessageCipherDTO } from "../dto/MessageCipherDTO";
import { ChatModel } from "../model/ChatModel"; import { ChatModel } from "../../common/model/ChatModel";
import { Observer } from "../observe/Observer"; import { Observer } from "../observe/Observer";
import { EncryptionService } from "../service/EncryptionService"; import { EncryptionService } from "../service/EncryptionService";
import { MarkDownService } from "../service/MarkDownService"; import { MarkDownService } from "../service/MarkDownService";
@ -12,7 +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"; import { UserModel } from "../../common/model/UserModel";
export class ChatView implements Observer<ChatMessageViewModel> { export class ChatView implements Observer<ChatMessageViewModel> {
private readonly _chatModel: ChatModel; private readonly _chatModel: ChatModel;

View File

@ -1,9 +1,9 @@
import { ChatMessageViewModel } from "../viewmodel/ChatMessageViewModel"; import { ChatMessageViewModel } from "../viewmodel/ChatMessageViewModel";
import { ChatModel } from "../model/ChatModel"; import { ChatModel } from "../../common/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"; import { UserModel } from "../../common/model/UserModel";
export interface ChatViewDeps { export interface ChatViewDeps {
chatModel: ChatModel; chatModel: ChatModel;

View File

@ -1,10 +1,10 @@
import { Observer } from "../observe/Observer"; import { Observer } from "../observe/Observer";
import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel"; import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel";
import { ChatModel } from "../model/ChatModel"; import { ChatModel } from "../../common/model/ChatModel";
import log = require("loglevel"); import log = require("loglevel");
import * as DOMPurify from "dompurify"; import * as DOMPurify from "dompurify";
import { SearchService } from "../service/SearchService"; import { SearchService } from "../service/SearchService";
import { UserModel } from "../model/UserModel"; import { UserModel } from "../../common/model/UserModel";
import { UserViewDeps } from "./UserViewDeps"; import { UserViewDeps } from "./UserViewDeps";
import { ObserverData } from "../observe/ObserverData"; import { ObserverData } from "../observe/ObserverData";
import { JsonAPI } from "../singleton/JsonAPI"; import { JsonAPI } from "../singleton/JsonAPI";

View File

@ -1,6 +1,6 @@
import { UserModel } from "../model/UserModel"; import { UserModel } from "../../common/model/UserModel";
import { ChatModel } from "../model/ChatModel"; import { ChatModel } from "../../common/model/ChatModel";
import { SearchService } from "../service/SearchService"; import { SearchService } from "../service/SearchService";

View File

@ -0,0 +1,7 @@
import { Subject } from "../../chat/observe/Observable";
import { ActiveUserViewModel } from "../../chat/viewmodel/ActiveUserViewModel";
export interface Model extends Subject<any> {
someBusinessMethod(data: Object): void;
}

View File

@ -1,11 +1,11 @@
import { Subject } from "../observe/Observable"; import { Subject } from "../../chat/observe/Observable";
import { Observer } from "../observe/Observer"; import { Observer } from "../../chat/observe/Observer";
import { JsonAPI } from "../singleton/JsonAPI"; import { JsonAPI } from "../../chat/singleton/JsonAPI";
import { ChatMessageViewModel } from "../viewmodel/ChatMessageViewModel"; import { ChatMessageViewModel } from "../../chat/viewmodel/ChatMessageViewModel";
import { ChatModelHelper } from "./ChatModelHelper"; import { ChatModelHelper } from "./ChatModelHelper";
import log = require("loglevel"); import log = require("loglevel");
import { ObserverData } from "../observe/ObserverData"; import { ObserverData } from "../../chat/observe/ObserverData";
import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel"; import { ActiveUserViewModel } from "../../chat/viewmodel/ActiveUserViewModel";
import moment = require("moment"); import moment = require("moment");
interface Params { interface Params {

View File

@ -1,10 +1,10 @@
import * as log from "loglevel"; import * as log from "loglevel";
import { ChatMessageDTO } from "../dto/ChatMessageDTO"; import { ChatMessageDTO } from "../../chat/dto/ChatMessageDTO";
import { EncryptionService } from "../service/EncryptionService"; import { EncryptionService } from "../../chat/service/EncryptionService";
import { NotificationService } from "../service/NotificationService"; import { NotificationService } from "../../chat/service/NotificationService";
import { JsonAPI } from "../singleton/JsonAPI"; import { JsonAPI } from "../../chat/singleton/JsonAPI";
import { Sprintf } from "../singleton/Sprintf"; import { Sprintf } from "../../chat/singleton/Sprintf";
import { ChatMessageViewModel } from "../viewmodel/ChatMessageViewModel"; import { ChatMessageViewModel } from "../../chat/viewmodel/ChatMessageViewModel";
import { fetchErrorHandler } from "./FetchErrorHandler"; import { fetchErrorHandler } from "./FetchErrorHandler";
export class ChatModelHelper { export class ChatModelHelper {

View File

@ -1,6 +1,6 @@
import log = require("loglevel"); import log = require("loglevel");
import { NotificationService } from "../service/NotificationService"; import { NotificationService } from "../../chat/service/NotificationService";
import { Sprintf } from "../singleton/Sprintf"; import { Sprintf } from "../../chat/singleton/Sprintf";
// import { sprintf } from "sprintf-js"; // import { sprintf } from "sprintf-js";
///<reference path="../SprintfTest.d.ts" /> ///<reference path="../SprintfTest.d.ts" />

View File

@ -1,10 +1,10 @@
import * as log from "loglevel"; import * as log from "loglevel";
import { Subject } from "../observe/Observable"; import { Subject } from "../../chat/observe/Observable";
import { Observer } from "../observe/Observer"; import { Observer } from "../../chat/observe/Observer";
import { JsonAPI } from "../singleton/JsonAPI"; import { JsonAPI } from "../../chat/singleton/JsonAPI";
import { ActiveUserViewModel } from "../viewmodel/ActiveUserViewModel"; import { ActiveUserViewModel } from "../../chat/viewmodel/ActiveUserViewModel";
import { fetchErrorHandler } from "./FetchErrorHandler"; import { fetchErrorHandler } from "./FetchErrorHandler";
import { NotificationService } from "../service/NotificationService"; import { NotificationService } from "../../chat/service/NotificationService";
export class UserModel implements Subject<ActiveUserViewModel> { export class UserModel implements Subject<ActiveUserViewModel> {
/** /**

View File

@ -2,7 +2,7 @@ import registerPromiseWorker from 'promise-worker/register';
import * as sjcl from 'sjcl' import * as sjcl from 'sjcl'
registerPromiseWorker((payload) => { registerPromiseWorker((payload: { passphrase: string, cipher: string }) => {
// console.log(payload) // console.log(payload)
// console.log('decrypted = ' + sjcl.decrypt(payload.passphrase, JSON.stringify(payload.cipher))); // console.log('decrypted = ' + sjcl.decrypt(payload.passphrase, JSON.stringify(payload.cipher)));
return sjcl.decrypt(payload.passphrase, JSON.stringify(payload.cipher)) return sjcl.decrypt(payload.passphrase, JSON.stringify(payload.cipher))