fix: Allow to have null folder for flows

This commit is contained in:
Faruk AYDIN
2025-02-14 12:03:07 +01:00
parent 6cbd642c2a
commit f0f5c8fc9a
2 changed files with 40 additions and 6 deletions

View File

@@ -351,17 +351,20 @@ class Flow extends Base {
async updateFolder(folderId) {
const user = await this.$relatedQuery('user');
if (folderId === null) {
return this.updateFolderReference(null);
}
const folder = await user
.$relatedQuery('folders')
.findOne({
id: folderId,
})
.findOne({ id: folderId })
.throwIfNotFound();
await this.$query().patch({
folderId: folder.id,
});
return this.updateFolderReference(folder.id);
}
async updateFolderReference(folderId) {
await this.$query().patch({ folderId });
return this.$query().withGraphFetched('folder');
}