remove sending to false on first loade page

This commit is contained in:
Peter Maquiran
2024-08-07 16:02:05 +01:00
parent d55450ccbb
commit b61b87ce6c
3 changed files with 20 additions and 1 deletions
@@ -80,6 +80,17 @@ export class MessageLocalDataSourceService {
// })
}
async setAllSenderToFalse() {
try {
await messageDataSource.transaction('rw', messageDataSource.message, async () => {
// Perform the update operation within the transaction
await messageDataSource.message.toCollection().modify({ sending: false });
});
console.log('All messages updated successfully.');
} catch (error) {
console.error('Error updating messages:', error);
}
}
async getLastMessageByRoomId(roomId: string): Promise<Result<undefined|TableMessage, any>> {
try {
@@ -41,6 +41,7 @@ export class MessageRepositoryService {
const requestId = InstanceId +'@'+ uuidv4();
const roomId = entity.roomId
entity.sending = true
const localActionResult = await this.messageLocalDataSourceService.sendMessage(entity)
if(localActionResult.isOk()) {
@@ -18,7 +18,10 @@ export class SyncMessageRepositoryService {
private messageLiveDataSourceService: MessageLiveDataSourceService,
private messageLiveSignalRDataSourceService: SignalRService,
private messageLocalDataSourceService: MessageLocalDataSourceService
) { }
) {
// this.messageLocalDataSourceService.setAllSenderToFalse();
}
async sendLocalMessages() {
const messages = await this.messageLocalDataSourceService.getOfflineMessages()
@@ -26,8 +29,12 @@ export class SyncMessageRepositoryService {
if(messages.length >= 1) {
for(const message of messages) {
console.log('to upload', messages)
const requestId = InstanceId +'@'+ uuidv4();
const DTO = MessageMapper.fromDomain(message, requestId)
await this.messageLocalDataSourceService.update({sending: true, $id: message.$id})
const sendMessageResult = await this.messageLiveSignalRDataSourceService.sendMessage<MessageOutPutDataDTO>(DTO)
if(sendMessageResult.isOk()) {