improve chat

This commit is contained in:
Peter Maquiran
2022-02-03 21:01:53 +01:00
parent 33a2982805
commit 61de7b937b
13 changed files with 1147 additions and 668 deletions
+26 -18
View File
@@ -2,6 +2,8 @@ import { Injectable } from '@angular/core';
import { Message } from 'src/app/models/chatMethod';
import { chatHistory, ChatMessage, File } from 'src/app/models/chatMethod'
import { Storage } from '@ionic/storage';
import { SessionStore } from 'src/app/store/session.service';
import { capitalizeTxt } from 'src/plugin/text'
@Injectable({
providedIn: 'root'
@@ -17,28 +19,34 @@ export class MessageService {
u = {}
t = ''
_id =''
_updatedAt = ''
_updatedAt
file
attachments
offline = false
offline = true
constructor(private storage: Storage) {
}
}
setData({customFields, channels, mentions, msg ,rid ,ts, u, t, _id, _updatedAt, file, attachments}:Message) {
this.customFields = customFields
this.channels = channels
this.mentions = mentions
this.msg = msg
this.customFields = customFields
this.channels = channels || []
this.mentions = mentions || []
this.msg = msg || ""
this.rid = rid
this.ts = ts
this.u = u
this.u = u || { name: this.usernameToDisplayName(SessionStore.user.RochetChatUser), username: SessionStore.user.RochetChatUser, _id: ""}
this.t = t
this._id = _id
this._updatedAt = _updatedAt
this._updatedAt = _updatedAt || new Date().getTime()
this.file = file
this.attachments = attachments
if(!this.ts) {
this.offline = true
} else {
this.offline = false
}
if (this.file) {
if (this.file.guid) {
@@ -49,22 +57,22 @@ export class MessageService {
}
}
if(this.rid == 'offline') {
this.offline = true
} else {
this.offline = false
}
}
delete() {}
showDateDuration() {}
resend() {
}
private usernameToDisplayName(username) {
const firstName = capitalizeTxt(username.split('.')[0])
const lastName = capitalizeTxt(username.split('.')[1])
return firstName + ' ' + lastName
}
}