mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Fix scene marker/gallery chapter update overwriting created at date (#3945)
* Add UpdatePartial to gallery chapter * Add UpdatePartial to gallery marker * Fix UI, use yup and useFormik
This commit is contained in:
@@ -57,6 +57,19 @@ func (r *sceneMarkerRow) resolve() *models.SceneMarker {
|
||||
return ret
|
||||
}
|
||||
|
||||
type sceneMarkerRowRecord struct {
|
||||
updateRecord
|
||||
}
|
||||
|
||||
func (r *sceneMarkerRowRecord) fromPartial(o models.SceneMarkerPartial) {
|
||||
r.setNullString("title", o.Title)
|
||||
r.setFloat64("seconds", o.Seconds)
|
||||
r.setInt("primary_tag_id", o.PrimaryTagID)
|
||||
r.setInt("scene_id", o.SceneID)
|
||||
r.setTimestamp("created_at", o.CreatedAt)
|
||||
r.setTimestamp("updated_at", o.UpdatedAt)
|
||||
}
|
||||
|
||||
type SceneMarkerStore struct {
|
||||
repository
|
||||
|
||||
@@ -100,6 +113,24 @@ func (qb *SceneMarkerStore) Create(ctx context.Context, newObject *models.SceneM
|
||||
return nil
|
||||
}
|
||||
|
||||
func (qb *SceneMarkerStore) UpdatePartial(ctx context.Context, id int, partial models.SceneMarkerPartial) (*models.SceneMarker, error) {
|
||||
r := sceneMarkerRowRecord{
|
||||
updateRecord{
|
||||
Record: make(exp.Record),
|
||||
},
|
||||
}
|
||||
|
||||
r.fromPartial(partial)
|
||||
|
||||
if len(r.Record) > 0 {
|
||||
if err := qb.tableMgr.updateByID(ctx, id, r.Record); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return qb.find(ctx, id)
|
||||
}
|
||||
|
||||
func (qb *SceneMarkerStore) Update(ctx context.Context, updatedObject *models.SceneMarker) error {
|
||||
var r sceneMarkerRow
|
||||
r.fromSceneMarker(*updatedObject)
|
||||
|
||||
Reference in New Issue
Block a user