Merge pull request #74 from vcappuccio/fix/race-condition
Fix Incorrect Method Call and Potential Race Condition in src/db/index.ts
This commit is contained in:
		
						commit
						1b69ad9f08
					
				| @ -89,7 +89,7 @@ export class PageAssitDatabase { | |||||||
|     const history_id = message.history_id |     const history_id = message.history_id | ||||||
|     const chatHistory = await this.getChatHistory(history_id) |     const chatHistory = await this.getChatHistory(history_id) | ||||||
|     const newChatHistory = [message, ...chatHistory] |     const newChatHistory = [message, ...chatHistory] | ||||||
|     this.db.set({ [history_id]: newChatHistory }) |     await this.db.set({ [history_id]: newChatHistory }) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async removeChatHistory(id: string) { |   async removeChatHistory(id: string) { | ||||||
| @ -112,12 +112,13 @@ export class PageAssitDatabase { | |||||||
|     this.db.clear() |     this.db.clear() | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async deleteChatHistory() { |   async deleteChatHistory(id: string) { | ||||||
|     const chatHistories = await this.getChatHistories() |     const chatHistories = await this.getChatHistories() | ||||||
|     for (const history of chatHistories) { |     const newChatHistories = chatHistories.filter( | ||||||
|       this.db.remove(history.id) |       (history) => history.id !== id | ||||||
|     } |     ) | ||||||
|     this.db.remove("chatHistories") |     this.db.set({ chatHistories: newChatHistories }) | ||||||
|  |     this.db.remove(id) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async deleteMessage(history_id: string) { |   async deleteMessage(history_id: string) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user