mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
remove sending to false on first loade page
This commit is contained in:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user