Skip to content

Commit

Permalink
Fix crash caused by Twitch API returning pageInfo.hasNextPage but no …
Browse files Browse the repository at this point in the history
…video edges
  • Loading branch information
ScrubN committed Oct 28, 2024
1 parent 370d939 commit 98efccf
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions TwitchDownloaderWPF/WindowMassDownload.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,18 @@ private async Task UpdateList()
});
}

btnNext.IsEnabled = res.data.user.videos.pageInfo.hasNextPage;
btnPrev.IsEnabled = res.data.user.videos.pageInfo.hasPreviousPage;
if (res.data.user.videos.pageInfo.hasNextPage)
{
string newCursor = res.data.user.videos.edges[0].cursor;
if (!cursorList.Contains(newCursor))
cursorList.Add(newCursor);
string newCursor = res.data.user.videos.edges.FirstOrDefault()?.cursor;
if (newCursor is not null)
{
btnNext.IsEnabled = true;
if (!cursorList.Contains(newCursor))
{
cursorList.Add(newCursor);
}
}
}
}
}
Expand Down Expand Up @@ -184,13 +189,18 @@ private async Task UpdateList()
});
}

btnNext.IsEnabled = res.data.user.clips.pageInfo.hasNextPage;
btnPrev.IsEnabled = cursorIndex >= 0;
if (res.data.user.clips.pageInfo.hasNextPage)
{
string newCursor = res.data.user.clips.edges.First(x => x.cursor != null).cursor;
if (!cursorList.Contains(newCursor))
cursorList.Add(newCursor);
string newCursor = res.data.user.clips.edges.FirstOrDefault(x => x.cursor != null)?.cursor;
if (newCursor is not null)
{
btnNext.IsEnabled = true;
if (!cursorList.Contains(newCursor))
{
cursorList.Add(newCursor);
}
}
}
}
}
Expand Down

0 comments on commit 98efccf

Please sign in to comment.