Skip to content

Commit

Permalink
improve(desktop): improve clearing history messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Red-Asuka authored and ysfscream committed Dec 21, 2022
1 parent f458453 commit b6fa0f8
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/database/services/MessageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,10 @@ export default class MessageService {
}

public async cleanInConnection(connectionId: string) {
const query: MessageEntity[] | undefined = await this.messageRepository
.createQueryBuilder('ms')
.where('ms.connectionId = :connectionId', { connectionId })
.getMany()
if (!query || !query.length) {
return
}
const deleteID: string[] = []
query.forEach((entity) => {
entity.id && deleteID.push(entity.id)
})
if (!deleteID.length) {
return
}
await this.messageRepository.delete(deleteID)
await this.messageRepository
.createQueryBuilder()
.delete()
.where('connectionId = :connectionId', { connectionId })
.execute()
}
}

0 comments on commit b6fa0f8

Please sign in to comment.