diff --git a/api/history.go b/api/history.go index 05d5fa19..a3e81760 100644 --- a/api/history.go +++ b/api/history.go @@ -6,6 +6,7 @@ import ( "github.com/elgatito/elementum/database" "github.com/elgatito/elementum/xbmc" + "github.com/asdine/storm" "github.com/gin-gonic/gin" ) @@ -23,10 +24,7 @@ func History(ctx *gin.Context) { items := []*xbmc.ListItem{} var ths []database.TorrentHistory - if err := database.GetStormDB().All(&ths); err != nil { - log.Infof("Could not get list of history items: %s", err) - } - if err := database.GetStormDB().AllByIndex("Dt", &ths); err != nil { + if err := database.GetStormDB().AllByIndex("Dt", &ths, storm.Reverse()); err != nil { log.Infof("Could not get list of history items: %s", err) } diff --git a/api/torrents.go b/api/torrents.go index 647ddad0..ada823dd 100644 --- a/api/torrents.go +++ b/api/torrents.go @@ -106,7 +106,7 @@ func InTorrentsMap(tmdbID string) *bittorrent.TorrentFile { // InTorrentsHistory ... func InTorrentsHistory(infohash string) *bittorrent.TorrentFile { - if !config.Get().UseTorrentHistory { + if !config.Get().UseTorrentHistory || infohash == "" { return nil }