Use safe remove (#106)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina
2025-09-24 23:44:36 +04:00
committed by GitHub
parent 7afc4f0c88
commit 86473f96ce
+12 -8
View File
@@ -336,8 +336,9 @@ export class Blob {
async removeMessage (cardId: CardID, blobId: BlobID, messageId: MessageID): Promise<void> {
const patches: JsonPatch[] = [
{
op: 'remove',
path: `/messages/${messageId}`
hop: 'remove',
path: `/messages/${messageId}`,
safe: true
} as const
]
@@ -369,8 +370,9 @@ export class Blob {
async removeReaction (cardId: CardID, blobId: BlobID, messageId: MessageID, emoji: string, person: PersonUuid): Promise<void> {
const patches: JsonPatch[] = [
{
op: 'remove',
path: `/messages/${messageId}/reactions/${emoji}/${person}`
hop: 'remove',
path: `/messages/${messageId}/reactions/${emoji}/${person}`,
safe: true
}
]
await this.patchJson(cardId, blobId, patches)
@@ -394,8 +396,9 @@ export class Blob {
for (const attachmentId of attachmentIds) {
patches.push({
op: 'remove',
path: `/messages/${messageId}/attachments/${attachmentId}`
hop: 'remove',
path: `/messages/${messageId}/attachments/${attachmentId}`,
safe: true
})
}
await this.patchJson(cardId, blobId, patches)
@@ -506,8 +509,9 @@ export class Blob {
async removeThread (cardId: CardID, blobId: BlobID, messageId: MessageID, threadId: CardID): Promise<void> {
const patches: JsonPatch[] = [
{
op: 'remove',
path: `/messages/${messageId}/threads/${threadId}`
hop: 'remove',
path: `/messages/${messageId}/threads/${threadId}`,
safe: true
}
]
await this.patchJson(cardId, blobId, patches)