Skip to content

Commit

Permalink
Fix: Edited Duration not saved (#1437)
Browse files Browse the repository at this point in the history
* Edited Duration not saved

* Fix saves with no durnation change
  • Loading branch information
toshski authored Oct 25, 2023
1 parent 81d8231 commit 25d9929
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pkg/api/scenes.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type RequestEditSceneDetails struct {
Images string `json:"images"`
CoverURL string `json:"cover_url"`
IsMultipart bool `json:"is_multipart"`
Duration string `json:"duration"`
}

type ResponseGetScenes struct {
Expand Down Expand Up @@ -804,7 +805,10 @@ func (i SceneResource) editScene(req *restful.Request, resp *restful.Response) {
scene.IsMultipart = r.IsMultipart
models.AddAction(scene.SceneID, "edit", "is_multipart", strconv.FormatBool(r.IsMultipart))
}

if strconv.Itoa(scene.Duration) != r.Duration {
scene.Duration, _ = strconv.Atoi(r.Duration)
models.AddAction(scene.SceneID, "edit", "duration", r.Duration)
}
ProcessTagChanges(&scene, &r.Tags, db)

newCast := make([]models.Actor, 0)
Expand Down
9 changes: 7 additions & 2 deletions pkg/tasks/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,15 @@ func ReapplyEdits() {
continue
}
// Reapply other edits
db.Model(&scene).Update(a.ChangedColumn, a.NewValue)
if a.ChangedColumn == "release_date_text" {
switch a.ChangedColumn {
case "duration":
i, _ := strconv.Atoi(a.NewValue)
db.Model(&scene).Update(a.ChangedColumn, i)
case "release_date_text":
dt, _ := time.Parse("2006-01-02", a.NewValue)
db.Model(&scene).Update("release_date", dt)
default:
db.Model(&scene).Update(a.ChangedColumn, a.NewValue)
}
}
db.Model(&models.Scene{}).UpdateColumn("edits_applied", true)
Expand Down
1 change: 1 addition & 0 deletions ui/src/views/scenes/EditScene.vue
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export default {
this.scene.images = JSON.stringify(images)
this.scene.cover_url = this.scene.covers[0]
this.scene.filenames_arr = JSON.stringify(this.scene.files)
this.scene.duration = String(this.scene.duration) // force to a string, if no change the UI sends an int, otherwise a string, nust be constant
ky.post(`/api/scene/edit/${this.scene.id}`, { json: { ...this.scene } })
Expand Down

0 comments on commit 25d9929

Please sign in to comment.