Skip to content

Commit

Permalink
remove nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
adnaan committed Mar 2, 2024
1 parent bc3efb6 commit 5e37510
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions render.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,12 @@ func getUnsetErrorEvents(cch *cache.Cache, sessionID *string, events []dom.Event

// get previously set errors from cache
prevErrors := make(map[string]string)
if sessionID != nil {
v, ok := cch.Get(*sessionID)
if ok {
prevErrors, ok = v.(map[string]string)
if !ok {
panic("fir: cache value is not a map[string]string")
}

v, ok := cch.Get(*sessionID)
if ok {
prevErrors, ok = v.(map[string]string)
if !ok {
panic("fir: cache value is not a map[string]string")
}
}

Expand All @@ -254,9 +253,8 @@ func getUnsetErrorEvents(cch *cache.Cache, sessionID *string, events []dom.Event
currErrors[*event.Type] = *event.Target
}
// set new errors in cache
if sessionID != nil {
cch.Set(*sessionID, currErrors, cache.DefaultExpiration)
}

cch.Set(*sessionID, currErrors, cache.DefaultExpiration)

// explicitly unset previously set errors that are not in new errors
// this means generating an event with empty detail
Expand Down

0 comments on commit 5e37510

Please sign in to comment.