diff --git a/apps/tagtree.c b/apps/tagtree.c index 575ab22..797411c 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c @@ -1231,6 +1231,8 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init) { dptr->newtable = PLAYTRACK; dptr->extraseek = tcs.idx_id; + dptr->lastplayed = tagcache_get_numeric(&tcs, tag_lastplayed); + // DEBUGF("age = %ld", tagcache_get_numeric(&tcs, tag_lastplayed)); } else dptr->extraseek = tcs.result_seek; @@ -1353,8 +1355,21 @@ static int retrieve_entries(struct tree_context *c, int offset, bool init) } } - return total_count; + if (true) /* find youngest. XXX merge with loop in previous clause */ + { + long lastplayed = 0; + dptr = c->dircache; + for (i = 0; i < total_count; i++, dptr++) + { + if (dptr->newtable == PLAYTRACK && lastplayed < dptr->lastplayed) + { + lastplayed = dptr->lastplayed; + c->selected_item = i; + } + } + } + return total_count; } static int load_root(struct tree_context *c) diff --git a/apps/tagtree.h b/apps/tagtree.h index aaf5158..6b01acb 100644 --- a/apps/tagtree.h +++ b/apps/tagtree.h @@ -34,6 +34,7 @@ struct tagentry { char *name; int newtable; int extraseek; + long lastplayed; }; bool tagtree_export(void);