Browse Source

Fixed edit functions not detecting changes correctly

1.0
Gisle Aune 6 years ago
parent
commit
bae15de3e8
  1. 2
      model/story/chapter.go
  2. 10
      model/story/story.go

2
model/story/chapter.go

@ -41,7 +41,7 @@ func (chapter *Chapter) Edit(title, source *string, fictionalDate *time.Time) er
changes["source"] = *source
changed.Source = *source
}
if fictionalDate != nil && *fictionalDate != chapter.FictionalDate {
if fictionalDate != nil && !fictionalDate.Equal(chapter.FictionalDate) {
changes["fictionalDate"] = *fictionalDate
changed.FictionalDate = *fictionalDate
}

10
model/story/story.go

@ -84,23 +84,23 @@ func (story *Story) Edit(name, category *string, listed, open *bool, fictionalDa
changes := bson.M{}
changed := *story
if name != nil && *name == story.Name {
if name != nil && *name != story.Name {
changes["name"] = *name
changed.Name = *name
}
if category != nil && *category == story.Category {
if category != nil && *category != story.Category {
changes["category"] = *category
changed.Name = *category
}
if listed != nil && *listed == story.Listed {
if listed != nil && *listed != story.Listed {
changes["listed"] = *listed
changed.Listed = *listed
}
if open != nil && *open == story.Open {
if open != nil && *open != story.Open {
changes["open"] = *open
changed.Open = *open
}
if fictionalDate != nil && *fictionalDate == story.FictionalDate {
if fictionalDate != nil && !fictionalDate.Equal(story.FictionalDate) {
changes["fictionalDate"] = *fictionalDate
changed.FictionalDate = *fictionalDate
}

Loading…
Cancel
Save