aboutsummaryrefslogtreecommitdiff
path: root/c/episodelistview.c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-04-06 23:07:39 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-04-06 23:07:39 +0200
commitca091cc1be997b981c2980fb8d2865f2bcfee65b (patch)
treeb59c146e7107021c5bc5295e7cbb640d14274ee7 /c/episodelistview.c
parent34c0940e6cd6d222f2234d81433fef38ca3a3738 (diff)
downloadEpisodeBrowser-ca091cc1be997b981c2980fb8d2865f2bcfee65b.tar.gz
Fix most recent episode selection when "View Watched" is disabled.
Diffstat (limited to 'c/episodelistview.c')
-rw-r--r--c/episodelistview.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/c/episodelistview.c b/c/episodelistview.c
index 1ce49b1..925ce23 100644
--- a/c/episodelistview.c
+++ b/c/episodelistview.c
@@ -135,7 +135,7 @@ ElvSetTop(int iItem)
void
ElvSelectRecent()
{
- int iEpisode, iItem;
+ int i, iEpisode, iItem;
LVFINDINFO lvfi;
term_t t;
@@ -144,14 +144,15 @@ ElvSelectRecent()
P("track_episodes","most_recently_watched",1,t) goto s;
GI(t,&iEpisode) return;
+ i = 0;
lvfi.flags = LVFI_PARAM;
lvfi.lParam = iEpisode;
-
- iItem = ListView_FindItem(HElv, -1, &lvfi);
+ do
+ lvfi.lParam = iEpisode+i;
+ while ((iItem = ListView_FindItem(HElv, -1, &lvfi)) == -1 && i++ < 100);
if (iItem == -1) return;
-s:
- ListView_SetItemState(HElv, -1, LVIF_STATE, LVIS_SELECTED);
+s: ListView_SetItemState(HElv, -1, LVIF_STATE, LVIS_SELECTED);
ElvSetTop(iItem > 5? iItem-5: 0);
ListView_SetItemState(HElv, iItem,
LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);