mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
fix message order on reconect
This commit is contained in:
@@ -6,6 +6,9 @@
|
||||
},
|
||||
{
|
||||
"path": "../sentium"
|
||||
},
|
||||
{
|
||||
"path": "../sentium-api"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Observable as DexieObservable, PromiseExtended } from 'Dexie';
|
||||
import { DexieMessageTable, MessageTable, MessageTableSchema } from 'src/app/infra/database/dexie/instance/chat/schema/message';
|
||||
import { chatDatabase } from 'src/app/infra/database/dexie/instance/chat/service';
|
||||
import { IDirectMessages, IMessageLocalRepository } from 'src/app/core/chat/repository/message/message-local-repository';
|
||||
import { BehaviorSubject, combineLatest, from, Observable } from 'rxjs';
|
||||
import { BehaviorSubject, combineLatest, from, Observable, Subject } from 'rxjs';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { err, ok } from 'neverthrow';
|
||||
@@ -16,7 +16,7 @@ import { err, ok } from 'neverthrow';
|
||||
})
|
||||
export class MessageLocalDataSourceService extends DexieRepository<MessageTable, MessageEntity, DexieMessageTable> implements IMessageLocalRepository {
|
||||
|
||||
private creatingSubject : BehaviorSubject<MessageTable> = new BehaviorSubject<MessageTable>(null);
|
||||
private creatingSubject : Subject<MessageTable> = new Subject<MessageTable>();
|
||||
private lastTimestamp = 0;
|
||||
|
||||
constructor() {
|
||||
|
||||
@@ -369,19 +369,24 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.messageOnReconnectSubject?.unsubscribe()
|
||||
this.messageOnReconnectSubject = this.chatServiceService.listenToMessageLoadHistory({roomId: this.room.id}).subscribe((messages) => {
|
||||
|
||||
for(const message of messages.data) {
|
||||
for(const message of messages.data.reverse()) {
|
||||
const found = this.messages1[this.room.$id].find((e) => e.id == message.id)
|
||||
|
||||
if(!found) {
|
||||
|
||||
const date = whatsappDate(message.sentAt, false)
|
||||
if(!this.date[date]) {
|
||||
this.date[date] = true
|
||||
const Ballon = XBallon(message)
|
||||
this.messages1[this.room.$id].push(Ballon)
|
||||
}
|
||||
|
||||
const msg = new MessageViewModal(message as any)
|
||||
Object.assign(msg, message)
|
||||
this.messages1[this.room.$id].push(msg)
|
||||
}
|
||||
}
|
||||
|
||||
this.messages1[this.room.$id].sort((a, b) => {
|
||||
return new Date(a.sentAt).getTime() - new Date(b.sentAt).getTime()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import { MessageLocalDataSourceService } from 'src/app/module/chat/data/reposito
|
||||
import { whatsappDate } from '../../shared/utils/whatappdate';
|
||||
import { XBallon } from '../utils/messageBallon';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { RoomTable } from 'src/app/infra/database/dexie/instance/chat/schema/room';
|
||||
import { RoomLocalRepository } from 'src/app/module/chat/data/repository/room/room-local-repository.service'
|
||||
import { RoomViewModel } from './model/room';
|
||||
import { IDBoolean } from 'src/app/infra/database/dexie/type';
|
||||
@@ -16,7 +15,6 @@ import { Observable as DexieObservable } from 'Dexie';
|
||||
import { tap } from 'rxjs/operators';
|
||||
import { MemberTable } from 'src/app/infra/database/dexie/instance/chat/schema/members';
|
||||
import { MessageTable } from 'src/app/infra/database/dexie/instance/chat/schema/message';
|
||||
import { TypingTable } from 'src/app/infra/database/dexie/instance/chat/schema/typing';
|
||||
import { MemberListLocalRepository } from 'src/app/module/chat/data/repository/member/member-list-local-repository.service'
|
||||
import { UserTypingLocalRepository } from 'src/app/module/chat/data/repository/typing/user-typing-local-data-source.service';
|
||||
import { Result } from 'neverthrow';
|
||||
@@ -369,9 +367,16 @@ export class RoomStore {
|
||||
this.messageOnReconnectSubject?.unsubscribe()
|
||||
this.messageOnReconnectSubject = this.chatServiceService.listenToMessageLoadHistory({roomId: this.room.id}).subscribe((messages) => {
|
||||
|
||||
for(const message of messages.data) {
|
||||
for(const message of messages.data.reverse()) {
|
||||
const found = this.messages1[this.room.$id].find((e) => e.id == message.id)
|
||||
|
||||
const date = whatsappDate(message.sentAt, false)
|
||||
if(!this.date[date]) {
|
||||
this.date[date] = true
|
||||
const Ballon = XBallon(message)
|
||||
this.messages1[this.room.$id].push(Ballon)
|
||||
}
|
||||
|
||||
if(!found) {
|
||||
const msg = new MessageViewModal(message as any)
|
||||
Object.assign(msg, message)
|
||||
@@ -379,9 +384,7 @@ export class RoomStore {
|
||||
}
|
||||
}
|
||||
|
||||
this.messages1[this.room.$id].sort((a, b) => {
|
||||
return new Date(a.sentAt).getTime() - new Date(b.sentAt).getTime()
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
export let versionData = {
|
||||
"shortSHA": "e626883b5",
|
||||
"SHA": "e626883b5c0bb91a6fe9591eab1bf0b84a7c1d6b",
|
||||
"shortSHA": "9c65bee69",
|
||||
"SHA": "9c65bee69c06222e66bc5e392de880411bff3d98",
|
||||
"branch": "feature/chat-new-api-peter",
|
||||
"lastCommitAuthor": "'Peter Maquiran'",
|
||||
"lastCommitTime": "'Wed Oct 9 08:56:34 2024 +0100'",
|
||||
"lastCommitMessage": "fix audio icon",
|
||||
"lastCommitNumber": "6089",
|
||||
"changeStatus": "On branch feature/chat-new-api-peter\nYour branch is ahead of 'origin/feature/chat-new-api-peter' by 4 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: gabinete-digital-fo.code-workspace\n\tnew file: src/app/core/chat/repository/member/member-socket-repository.ts\n\tmodified: src/app/infra/socket/signalR/signalR.ts\n\tmodified: src/app/infra/socket/type.ts\n\tmodified: src/app/module/chat/chat.module.ts\n\tnew file: src/app/module/chat/data/repository/member/member-socket-repository.service.ts\n\tmodified: src/app/module/chat/data/repository/room/room-local-repository.service.ts\n\tmodified: src/app/module/chat/domain/chat-service.service.ts\n\tmodified: src/app/module/chat/domain/use-case/member/-use-case.service.ts\n\tnew file: src/app/module/chat/domain/use-case/member/member-remove-socket-use-case.service.ts\n\tmodified: src/app/module/chat/domain/use-case/message/message-local-get-by-id.service.ts\n\tmodified: src/app/ui/chat/component/group-contacts/group-contacts.page.ts\n\tmodified: src/app/ui/chat/modal/chat-popover/chat-popover.page.html\n\tmodified: src/app/ui/chat/modal/messages/messages.page.scss\n\tmodified: version/git-version.ts",
|
||||
"lastCommitTime": "'Wed Oct 9 16:28:51 2024 +0100'",
|
||||
"lastCommitMessage": "add member repository",
|
||||
"lastCommitNumber": "6090",
|
||||
"changeStatus": "On branch feature/chat-new-api-peter\nYour branch is ahead of 'origin/feature/chat-new-api-peter' by 5 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: gabinete-digital-fo.code-workspace\n\tmodified: src/app/module/chat/data/repository/message/message-local-data-source.service.ts\n\tmodified: src/app/ui/chat/component/messages/messages.page.ts\n\tmodified: src/app/ui/chat/store/roomStore.ts",
|
||||
"changeAuthor": "peter.maquiran"
|
||||
}
|
||||
Reference in New Issue
Block a user