Handle case when all items checked and cleared

This commit is contained in:
Balakrishnan Balasubramanian 2022-12-26 13:46:45 -05:00
parent 70b4b9b847
commit ea082ccc89
2 changed files with 7 additions and 2 deletions

View File

@ -96,7 +96,7 @@ func makeButtons(items []Entry) [][]button {
}
func (g *GList) GenSendListReq() ([]byte, error) {
req := newListReq{ChatID: g.ChatID, MessageID: g.MessageID, Text: "ok"}
req := newListReq{ChatID: g.ChatID, MessageID: g.MessageID, Text: "List:"}
itemButtons := makeButtons(g.Items)
controlButtons := []button{{"clear checked", "clear"}}
req.ReplyMarkup.InlineKeyboard = append(itemButtons, controlButtons)

View File

@ -101,11 +101,16 @@ func handleButtonClick(gl *glist.GList, messageID int, text string) {
gl.MessageID = &messageID
if text == "clear" {
gl.ClearChecked()
} else {
gl.Toggle(text)
}
sendList(gl, "editMessageText")
if len(gl.Items) == 0 {
deleteMessage(gl.ChatID, messageID)
} else {
sendList(gl, "editMessageText")
}
}
func sendList(gl *glist.GList, method string) {