parent
16c937d137
commit
8d313fa0e6
@ -14,6 +14,7 @@
|
|||||||
"handlebars": "^4.5.3",
|
"handlebars": "^4.5.3",
|
||||||
"loglevel": "^1.6.6",
|
"loglevel": "^1.6.6",
|
||||||
"markdown-it": "^10.0.0",
|
"markdown-it": "^10.0.0",
|
||||||
|
"moment": "^2.24.0",
|
||||||
"promise-worker": "^2.0.1",
|
"promise-worker": "^2.0.1",
|
||||||
"sjcl": "^1.0.8",
|
"sjcl": "^1.0.8",
|
||||||
"sprintf-js": "^1.1.2"
|
"sprintf-js": "^1.1.2"
|
||||||
|
@ -18,6 +18,7 @@ import { ChatViewDeps } from "./view/ChatViewDeps";
|
|||||||
import { UserView } from "./view/UserView";
|
import { UserView } from "./view/UserView";
|
||||||
import { UserViewDeps } from "./view/UserViewDeps";
|
import { UserViewDeps } from "./view/UserViewDeps";
|
||||||
import { ActiveUserViewModel } from "./viewmodel/ActiveUserViewModel";
|
import { ActiveUserViewModel } from "./viewmodel/ActiveUserViewModel";
|
||||||
|
import moment = require("moment");
|
||||||
|
|
||||||
log.setLevel("TRACE");
|
log.setLevel("TRACE");
|
||||||
|
|
||||||
@ -77,6 +78,12 @@ userController.getActiveUsers();
|
|||||||
Handlebars.registerHelper('avatar', function () {
|
Handlebars.registerHelper('avatar', function () {
|
||||||
return '<div class="img_cont_msg"> <img src="https://static.turbosquid.com/Preview/001292/481/WV/_D.jpg" class="rounded-circle user_img_msg"> </div>';
|
return '<div class="img_cont_msg"> <img src="https://static.turbosquid.com/Preview/001292/481/WV/_D.jpg" class="rounded-circle user_img_msg"> </div>';
|
||||||
});
|
});
|
||||||
|
Handlebars.registerHelper('fromNow', function (date: string) {
|
||||||
|
return moment(date).fromNow();
|
||||||
|
})
|
||||||
|
Handlebars.registerHelper('msgDateFormat', function(date: string) {
|
||||||
|
return moment(date).calendar(moment.now(), {lastWeek: "DD/MM/YY hh:mm:a", sameElse: "DD/MM/YY hh:mm:a"})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ export class ChatView implements Observer<ChatMessageViewModel> {
|
|||||||
} break;
|
} break;
|
||||||
case "new": {
|
case "new": {
|
||||||
const rev: ChatMessageViewModel[] = Object.create(cd.data)
|
const rev: ChatMessageViewModel[] = Object.create(cd.data)
|
||||||
rev.reverse();
|
// rev.reverse();
|
||||||
let arr: string[] = [];
|
let arr: string[] = [];
|
||||||
rev.forEach((vm: ChatMessageViewModel) => {
|
rev.forEach((vm: ChatMessageViewModel) => {
|
||||||
const vmTemp: ChatMessageViewModel = { ...vm };
|
const vmTemp: ChatMessageViewModel = { ...vm };
|
||||||
@ -67,7 +67,7 @@ export class ChatView implements Observer<ChatMessageViewModel> {
|
|||||||
else {
|
else {
|
||||||
rendered = DOMPurify.sanitize(this._messageReceiveTemplate(vmTemp));
|
rendered = DOMPurify.sanitize(this._messageReceiveTemplate(vmTemp));
|
||||||
}
|
}
|
||||||
$(this._messageContainer).prepend(rendered);
|
$(this._messageContainer).append(rendered);
|
||||||
});
|
});
|
||||||
$(this._messageContainer).stop().animate({
|
$(this._messageContainer).stop().animate({
|
||||||
scrollTop: $(this._messageContainer)[0].scrollHeight
|
scrollTop: $(this._messageContainer)[0].scrollHeight
|
||||||
@ -148,27 +148,24 @@ export class ChatView implements Observer<ChatMessageViewModel> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
const messageContent = chatInput.value;
|
const messageContent = chatInput.value;
|
||||||
const context = {
|
const msgTime = new Date();
|
||||||
fromUser: JsonAPI.principleName, toUser: "",
|
const context: ChatMessageViewModel = {
|
||||||
message: this._markdownService.render(messageContent),
|
fromUser: JsonAPI.principleName || "error",
|
||||||
messageTime: new Date().toLocaleString()
|
toUser: "",
|
||||||
|
message: messageContent,
|
||||||
|
messageTime: msgTime
|
||||||
};
|
};
|
||||||
// @ts-ignore
|
|
||||||
const msgContainer: string = this._messageSendTemplate(context);
|
this.update({data: new Array(context), op: "new"})
|
||||||
$(this._messageContainer).append(DOMPurify.sanitize(msgContainer));
|
|
||||||
// scrollChatAreaAnimated(2400);
|
|
||||||
// let messageCipher = sjcl.encrypt(passphraseInput.value, messageContent, { mode: "gcm", ts: 128, adata: "", iter: iterations });
|
|
||||||
let messageCipher: MessageCipherDTO = this._encryptionService.encrypt(passphraseInput.value, messageContent)
|
let messageCipher: MessageCipherDTO = this._encryptionService.encrypt(passphraseInput.value, messageContent)
|
||||||
// let messageCipherJson = JSON.parse(messageCipher);
|
|
||||||
let chatMessageDTO = {
|
let chatMessageDTO = {
|
||||||
"fromUser": JsonAPI.principleName,
|
"fromUser": JsonAPI.principleName || "",
|
||||||
"toUser": contactName,
|
"toUser": contactName,
|
||||||
"messageCipher": messageCipher,
|
"messageCipher": messageCipher,
|
||||||
// "messageTime": null
|
messageTime: msgTime
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
|
||||||
this._sendMessageAJAX(chatMessageDTO);
|
this._sendMessageAJAX(chatMessageDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1962,7 +1962,7 @@ module-deps@^6.0.0:
|
|||||||
through2 "^2.0.0"
|
through2 "^2.0.0"
|
||||||
xtend "^4.0.0"
|
xtend "^4.0.0"
|
||||||
|
|
||||||
moment@^2.10.2:
|
moment@^2.10.2, moment@^2.24.0:
|
||||||
version "2.24.0"
|
version "2.24.0"
|
||||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
|
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
|
||||||
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
|
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
|
||||||
|
@ -229,7 +229,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="msg msg_container">
|
<div class="msg msg_container">
|
||||||
{{{message}}}
|
{{{message}}}
|
||||||
<span class="msg_time">{{messageTime}}</span>
|
<span class="msg_time">{{msgDateFormat messageTime}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -238,7 +238,7 @@
|
|||||||
<div class="d-flex justify-content-end mb-4">
|
<div class="d-flex justify-content-end mb-4">
|
||||||
<div class="msg msg_container_send">
|
<div class="msg msg_container_send">
|
||||||
{{{message}}}
|
{{{message}}}
|
||||||
<span class="msg_time_send">{{messageTime}}</span>
|
<span class="msg_time_send">{{msgDateFormat messageTime}}</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="img_cont_msg">
|
<!-- <div class="img_cont_msg">
|
||||||
<img src="https://static.turbosquid.com/Preview/001292/481/WV/_D.jpg"
|
<img src="https://static.turbosquid.com/Preview/001292/481/WV/_D.jpg"
|
||||||
@ -274,7 +274,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="user_info">
|
<div class="user_info">
|
||||||
<span class="to-user-span">{{userName}}</span>
|
<span class="to-user-span">{{userName}}</span>
|
||||||
<p>Last active {{lastActive}}</p>
|
<p>Last active {{fromNow lastActive}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex flex-column ml-auto">
|
<div class="d-flex flex-column ml-auto">
|
||||||
<div class="text-right">Dec 25</div>
|
<div class="text-right">Dec 25</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user