Browse Source

graph2: Fixed last change closing all logs upon opening one, even the one just opened.

1.0
Gisle Aune 6 years ago
parent
commit
fc488b938d
  1. 2
      models/logs/add.go
  2. 2
      models/logs/edit.go

2
models/logs/add.go

@ -43,9 +43,9 @@ func Add(date time.Time, channelName, title, eventName, description string, open
// There can be only one open log in the same channel. TODO: Transaction
if open {
query := bson.M{
"_id": bson.M{"$ne": log.ID},
"open": true,
"channel": log.ChannelName,
"id": bson.M{"$ne": log.ID},
}
go collection.UpdateAll(query, bson.M{"$set": bson.M{"open": false}})

2
models/logs/edit.go

@ -38,9 +38,9 @@ func Edit(log models.Log, title *string, event *string, description *string, ope
// There can be only one open log. TODO: Transaction
if changes["open"] != nil && *open {
query := bson.M{
"_id": bson.M{"$ne": log.ID},
"open": true,
"channel": log.ChannelName,
"id": bson.M{"$ne": log.ID},
}
go collection.UpdateAll(query, bson.M{"$set": bson.M{"open": false}})

Loading…
Cancel
Save