Fix inline keyboard rows changing over time in /reminders and /pokedeks
Now all buttons are the same place every time.
This commit is contained in:
parent
73ae8c238e
commit
ef9cf07abc
@ -42,19 +42,16 @@ func (p *Pokedexer) pokememesListingMessage(update *tgbotapi.Update, page int, p
|
|||||||
func (p *Pokedexer) pokememesListingKeyboard(pokememesArray map[int]*datamapping.PokememeFull) *tgbotapi.InlineKeyboardMarkup {
|
func (p *Pokedexer) pokememesListingKeyboard(pokememesArray map[int]*datamapping.PokememeFull) *tgbotapi.InlineKeyboardMarkup {
|
||||||
keyboard := tgbotapi.InlineKeyboardMarkup{}
|
keyboard := tgbotapi.InlineKeyboardMarkup{}
|
||||||
rows := make(map[int][]tgbotapi.InlineKeyboardButton)
|
rows := make(map[int][]tgbotapi.InlineKeyboardButton)
|
||||||
rows[0] = []tgbotapi.InlineKeyboardButton{}
|
rowsCount := int(len(pokememesArray) / (35 * 7))
|
||||||
if len(pokememesArray) > 35*7 {
|
for i := 0; i <= rowsCount; i++ {
|
||||||
rows[1] = []tgbotapi.InlineKeyboardButton{}
|
rows[i] = []tgbotapi.InlineKeyboardButton{}
|
||||||
}
|
|
||||||
if len(pokememesArray) > 35*14 {
|
|
||||||
rows[2] = []tgbotapi.InlineKeyboardButton{}
|
|
||||||
}
|
}
|
||||||
totalPages := int(len(pokememesArray)/35) + 1
|
totalPages := int(len(pokememesArray)/35) + 1
|
||||||
for i := 1; i <= totalPages; i++ {
|
for i := 1; i <= totalPages; i++ {
|
||||||
btn := tgbotapi.NewInlineKeyboardButtonData(strconv.Itoa(i), "pokedeks"+strconv.Itoa(i))
|
btn := tgbotapi.NewInlineKeyboardButtonData(strconv.Itoa(i), "pokedeks"+strconv.Itoa(i))
|
||||||
rows[(i-1)/7] = append(rows[(i-1)/7], btn)
|
rows[(i-1)/7] = append(rows[(i-1)/7], btn)
|
||||||
}
|
}
|
||||||
for i := range rows {
|
for i := 0; i <= rowsCount; i++ {
|
||||||
keyboard.InlineKeyboard = append(keyboard.InlineKeyboard, rows[i])
|
keyboard.InlineKeyboard = append(keyboard.InlineKeyboard, rows[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ func (r *Reminder) formatRemindersButtons(playerRaw *dbmapping.Player) tgbotapi.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range rows {
|
for i := 0; i <= 2; i++ {
|
||||||
keyboard.InlineKeyboard = append(keyboard.InlineKeyboard, rows[i])
|
keyboard.InlineKeyboard = append(keyboard.InlineKeyboard, rows[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user