From 2c70ee8e330d744f24b977bef83ac7c570ff5382 Mon Sep 17 00:00:00 2001 From: Laptop Date: Sat, 26 Oct 2024 23:00:08 +0300 Subject: [PATCH] fix pagination (pagination may not immediately return you something, so automatically proceed until something useful is found) --- lib/sc/init.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/sc/init.go b/lib/sc/init.go index d33d560..1418684 100644 --- a/lib/sc/init.go +++ b/lib/sc/init.go @@ -210,6 +210,14 @@ func (p *Paginated[T]) Proceed() error { p.Next = "" } + // in soundcloud api, pagination may not immediately return you something! + // loading users who haven't released anything recently may require you to do a bunch of requests for nothing :/ + // maybe there could be a way to cache the last useless layer of pagination so soundcloak can start loading from there? might be a bit complicated, but would be great + if len(p.Collection) == 0 && p.Next != "" { + // this will make sure that we actually proceed to something useful and not emptiness + return p.Proceed() + } + return nil }