reset ticker on directory change

This commit is contained in:
andrzej 2024-11-04 21:28:55 +01:00
parent bd63efeeb7
commit 8988cab87d
1 changed files with 3 additions and 1 deletions

View File

@ -11,7 +11,8 @@ import (
func slideshow(ch <-chan string) {
dir := <-ch
ticker := time.NewTicker(time.Duration(config.Duration) * time.Minute)
duration := time.Duration(config.Duration) * time.Minute
ticker := time.NewTicker(duration)
go func() {
for {
@ -23,6 +24,7 @@ func slideshow(ch <-chan string) {
select {
case dir = <-ch:
log.Println("directory set!")
ticker.Reset(duration)
continue
case <-ticker.C:
continue