diff --git a/contentcuration/contentcuration/frontend/channelEdit/views/trash/TrashModal.vue b/contentcuration/contentcuration/frontend/channelEdit/views/trash/TrashModal.vue index 9052cf5720..271d12a8d0 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/views/trash/TrashModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/views/trash/TrashModal.vue @@ -281,19 +281,24 @@ 'moveContentNodes', 'loadContentNodes', 'loadAncestors', + 'removeContentNodes', ]), loadNodes() { this.loading = true; + this.more = null; + this.moreLoading = false; if (!this.trashId) { this.loading = false; return; } - this.loadChildren({ parent: this.trashId, ordering: '-modified' }).then( - childrenResponse => { - this.loading = false; - this.more = childrenResponse.more || null; - }, - ); + this.removeContentNodes({ parentId: this.trashId }).then(() => { + this.loadChildren({ parent: this.trashId, ordering: '-modified' }).then( + childrenResponse => { + this.loading = false; + this.more = childrenResponse.more || null; + }, + ); + }); }, moveNodes(target) { return this.moveContentNodes({ diff --git a/contentcuration/contentcuration/frontend/shared/data/__tests__/ContentNodeResource.spec.js b/contentcuration/contentcuration/frontend/shared/data/__tests__/ContentNodeResource.spec.js index 3f16719252..31bcb53bb4 100644 --- a/contentcuration/contentcuration/frontend/shared/data/__tests__/ContentNodeResource.spec.js +++ b/contentcuration/contentcuration/frontend/shared/data/__tests__/ContentNodeResource.spec.js @@ -574,8 +574,12 @@ describe('ContentNode methods', () => { it('should update the node with the payload', async () => { node.parent = parent.id; - await expect(ContentNode.tableMove({ node, parent, payload, change })).resolves.toBe(payload); - expect(table.update).toHaveBeenCalledWith(node.id, payload); + const result = await ContentNode.tableMove({ node, parent, payload, change }); + expect(result).toMatchObject({ ...payload, modified: expect.any(String) }); + expect(table.update).toHaveBeenCalledTimes(1); + const [updateId, updatePayload] = table.update.mock.calls[0]; + expect(updateId).toBe(node.id); + expect(updatePayload).toBe(result); expect(table.put).not.toBeCalled(); expect(table.update).not.toHaveBeenCalledWith(node.parent, { changed: true }); }); @@ -584,19 +588,23 @@ describe('ContentNode methods', () => { node.parent = parent.id; updated = false; const newPayload = { ...payload, root_id: parent.root_id }; - await expect(ContentNode.tableMove({ node, parent, payload, change })).resolves.toMatchObject( - newPayload, + const result = await ContentNode.tableMove({ node, parent, payload, change }); + expect(result).toMatchObject({ ...newPayload, modified: expect.any(String) }); + expect(table.update).toHaveBeenCalledWith( + node.id, + expect.objectContaining({ ...payload, modified: expect.any(String) }), ); - expect(table.update).toHaveBeenCalledWith(node.id, payload); - expect(table.put).toHaveBeenCalledWith(newPayload); + expect(table.put).toHaveBeenCalledWith(result); expect(table.update).not.toHaveBeenCalledWith(node.parent, { changed: true }); }); it('should mark the old parent as changed', async () => { - await expect(ContentNode.tableMove({ node, parent, payload, change })).resolves.toMatchObject( - payload, + const result = await ContentNode.tableMove({ node, parent, payload, change }); + expect(result).toMatchObject({ ...payload, modified: expect.any(String) }); + expect(table.update).toHaveBeenCalledWith( + node.id, + expect.objectContaining({ ...payload, modified: expect.any(String) }), ); - expect(table.update).toHaveBeenCalledWith(node.id, payload); expect(table.put).not.toBeCalled(); expect(table.update).toHaveBeenCalledWith(node.parent, { changed: true }); }); diff --git a/contentcuration/contentcuration/frontend/shared/data/resources.js b/contentcuration/contentcuration/frontend/shared/data/resources.js index 37c307d850..1ddc0cdbfe 100644 --- a/contentcuration/contentcuration/frontend/shared/data/resources.js +++ b/contentcuration/contentcuration/frontend/shared/data/resources.js @@ -1687,6 +1687,10 @@ export const ContentNode = new TreeResource({ async tableMove({ node, parent, payload }) { // Do direct table writes here rather than using add/update methods to avoid // creating unnecessary additional change events. + payload = { + ...payload, + modified: new Date().toISOString(), + }; const updated = await this.table.update(node.id, payload); // Update didn't succeed, this node probably doesn't exist, do a put instead, // but need to add in other parent info.