Bluelink: fix error if length of stamps is 0

This commit is contained in:
andig 2022-11-12 17:54:13 +01:00
parent 451be5e357
commit e1b19a3d87

View file

@ -1,6 +1,7 @@
package bluelink
import (
"errors"
"fmt"
"sync"
"time"
@ -55,6 +56,10 @@ func (c *stampCollection) Get() (string, error) {
position = int(time.Since(c.Generated).Milliseconds()) / c.Frequency
}
if len(c.Stamps) == 0 {
return "", errors.New("no stamps available")
}
if position >= len(c.Stamps) {
position = len(c.Stamps) - 1
}