Skip to content

Commit

Permalink
fix: cloned object
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Aug 16, 2024
1 parent 940db3f commit 9a585a1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion apps/core/src/modules/note/note.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ export class NoteController {
@Put('/:id')
@Auth()
async modify(@Body() body: NoteModel, @Param() params: MongoIdDto) {
return await this.noteService.updateById(params.id, body)
await this.noteService.updateById(params.id, body)
return this.noteService.findOneByIdOrNid(params.id)
}

@Patch('/:id')
Expand Down
9 changes: 4 additions & 5 deletions apps/core/src/modules/page/page.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ export class PageService {
this.imageService.saveImageDimensionsFromMarkdownText(
doc.text,
res.images,
(images) => {
async (images) => {
res.images = images
return res.save().then(() => {
this.eventManager.broadcast(BusinessEvents.PAGE_UPDATE, res, {
scope: EventScope.TO_SYSTEM,
})
await res.save()
this.eventManager.broadcast(BusinessEvents.PAGE_UPDATE, res, {
scope: EventScope.TO_SYSTEM,
})
},
)
Expand Down
2 changes: 2 additions & 0 deletions apps/core/src/modules/post/post.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ export class PostService {
})

const doc = newPost.toJSON()
const cloned = { ...doc }

// 双向关联
await this.relatedEachOther(doc, relatedIds)

scheduleManager.schedule(async () => {
const doc = cloned
await Promise.all([
this.imageService.saveImageDimensionsFromMarkdownText(
doc.text,
Expand Down
3 changes: 2 additions & 1 deletion apps/core/src/processors/helper/helper.image.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ export class ImageService implements OnModuleInit {
const result = [] as ImageModel[]

const oldImagesMap = new Map(
(originImages ?? []).map((image) => [image.src, image]),
(originImages ?? []).map((image) => [image.src, { ...image }]),
)

const task = [] as Promise<ImageModel>[]
for (const src of newImages) {
const originImage = oldImagesMap.get(src)
Expand Down

0 comments on commit 9a585a1

Please sign in to comment.