Skip to content

Commit

Permalink
bugfixing
Browse files Browse the repository at this point in the history
  • Loading branch information
nickali committed Aug 5, 2020
1 parent 707ca6e commit c7ae4f7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"
"fmt"
"log"
"strconv"
"sync"
"time"

Expand Down Expand Up @@ -54,7 +55,7 @@ func readConfig() bool {
return true
}

func writeUpdate(ctx context.Context, TopLeftLeft *text.Text, BottomLeft *text.Text, TopRight *text.Text, delay time.Duration) {
func writeUpdate(ctx context.Context, TopLeftLeft *text.Text, TopLeftRight *text.Text, BottomLeft *text.Text, TopRight *text.Text, delay time.Duration) {

ticker := time.NewTicker(delay)
defer ticker.Stop()
Expand All @@ -71,6 +72,15 @@ func writeUpdate(ctx context.Context, TopLeftLeft *text.Text, BottomLeft *text.T
}
}

stockwrappedText, stockwrappedOpt, stockwrappedState := stocks.Print(viper.GetString("stocks.symbol"), viper.GetString("stocks.api_key"))
for i, s := range stockwrappedText {
if stockwrappedState[i] != nil {
TopLeftRight.Write(s, stockwrappedState[i], stockwrappedOpt[i])
} else {
TopLeftRight.Write(s, stockwrappedOpt[i])
}
}

rsswrappedText, rsswrappedOpt, rsswrappedState := newsreader.Print(viper.GetString("newsreader.url"))
for i, s := range rsswrappedText {
if rsswrappedState[i] != nil {
Expand Down Expand Up @@ -182,7 +192,12 @@ func main() {
}
}

go writeUpdate(ctx, borderlessTopLeftLeft, borderlessBottomLeft, borderlessTopRight, 10*time.Second)
updateInterval, err := strconv.Atoi(viper.GetString("update_interval"))

if err != nil {
panic(err)
}
go writeUpdate(ctx, borderlessTopLeftLeft, borderlessTopLeftRight, borderlessBottomLeft, borderlessTopRight, time.Duration(updateInterval)*time.Second)

c, err := container.New(
t, container.ID(rootID),
Expand Down

0 comments on commit c7ae4f7

Please sign in to comment.