shop stuck fix (#284)

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
LightningTipBot 2022-01-12 11:16:47 +00:00 committed by GitHub
parent 95a22401b2
commit 7c95daabfd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -429,9 +429,12 @@ func (bot *TipBot) displayShopItem(ctx context.Context, m *tb.Message, shop *Sho
return nil
}
// failsafe: if the page is out of bounds, reset it
if shopView.Page >= len(shop.Items) {
if len(shop.Items) > 0 && shopView.Page >= len(shop.Items) {
shopView.Page = len(shop.Items) - 1
} else if len(shop.Items) == 0 {
shopView.Page = 0
}
log.Debugf("[displayShopItem] shop: %s page: %d", shop.ID, shopView.Page)
if len(shop.Items) == 0 {
no_items_message := "There are no items in this shop yet."