improve enter

This commit is contained in:
Peter Maquiran
2022-12-26 17:04:20 +01:00
parent 514288958a
commit bdb4192d84
10 changed files with 128 additions and 31 deletions
+37 -14
View File
@@ -71,7 +71,7 @@ export class MessageService {
private ChatSystemService: ChatSystemService) {
}
setData({customFields = {}, channels, mentions, msg ,rid ,ts, u, t, _id, id, _updatedAt, file, attachments, temporaryData, localReference , viewed = [], received = [], delate = false, delateRequest =false, from }:Message) {
setData({customFields = {}, channels, mentions, msg ,rid ,ts, u, t, _id, id, _updatedAt, file, attachments, temporaryData, localReference , viewed = [], received = [], delate = false, delateRequest =false, from, sendAttempt = 0 }:Message) {
this.channels = channels || []
this.mentions = mentions || []
@@ -88,6 +88,7 @@ export class MessageService {
this.id = id
this.delate = delate
this.delateRequest = delateRequest
this.sendAttempt = 0
if(this.attachments?.length >= 1 && attachments?.length >= 1) {
this.attachments[0] = Object.assign(this.attachments[0], attachments[0])
@@ -149,6 +150,7 @@ export class MessageService {
async send(): Promise<any> {
this.sendAttempt++;
this.manualRetry = false
if(!this.hasFile) {
@@ -220,7 +222,6 @@ export class MessageService {
functionTimer = null;
async sendRequest(params) {
if(params?.attachments) {
if(params?.attachments[0]?.image_url) {
delete params?.attachments[0]?.image_url
@@ -229,19 +230,39 @@ export class MessageService {
if(this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Online) {
// console.log('online send')
this.RochetChatConnectorService.send(params).then(
(ChatMessage: any) => {
ChatMessage = ChatMessage.message.result
clearTimeout(this.functionTimer);
this.messageSend = true
this.redefinedMessage(ChatMessage)
if(this.msg == '<script></script>') {
if(this.sendAttempt >= 4) {
this.RochetChatConnectorService.send(params).then(
(ChatMessage: any) => {
ChatMessage = ChatMessage.message.result
clearTimeout(this.functionTimer);
this.messageSend = true
this.redefinedMessage(ChatMessage)
}
).catch((error) => {
clearTimeout(this.functionTimer);
console.error(error)
})
}
).catch((error) => {
clearTimeout(this.functionTimer);
console.error(error)
})
} else {
this.RochetChatConnectorService.send(params).then(
(ChatMessage: any) => {
ChatMessage = ChatMessage.message.result
clearTimeout(this.functionTimer);
this.messageSend = true
this.redefinedMessage(ChatMessage)
}
).catch((error) => {
clearTimeout(this.functionTimer);
console.error(error)
})
}
this.functionTimer = setTimeout(() => {
@@ -264,7 +285,7 @@ export class MessageService {
this.RochetChatConnectorService.wsSend({message:{msg:"pong"}, loginRequired: false})
}, 8000)
}, 3000)
} else {
this.RochetChatConnectorService.registerCallback({
@@ -286,6 +307,8 @@ export class MessageService {
const message = this.getChatObj()
this.manualRetry = false
ChatMessage = Object.assign(message, ChatMessage)
this.setData(ChatMessage)