ft-sync/store/file/history.go
Simon Vieille 3af050caa0 add gorm
add history init/pull/push
2024-08-28 20:36:03 +02:00

27 lines
588 B
Go

package file
import (
"encoding/json"
config "gitnet.fr/deblan/freetube-sync/config/client"
"gitnet.fr/deblan/freetube-sync/file"
"gitnet.fr/deblan/freetube-sync/model"
)
func LoadHistory() []model.WatchedVideo {
lines := file.GetLines(config.GetConfig().DbPath("history"))
collection := []model.WatchedVideo{}
for _, line := range lines {
var item model.WatchedVideo
json.Unmarshal([]byte(line), &item)
collection = append(collection, item)
}
return collection
}
func UpdateHistory(data []string) {
file.WriteDatabase(config.GetConfig().DbPath("history"), data)
}