From ea082ccc8903e00bfe222647decf8d3ca8eb0bef Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Mon, 26 Dec 2022 13:46:45 -0500 Subject: [PATCH] Handle case when all items checked and cleared --- glist/glist.go | 2 +- main.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/glist/glist.go b/glist/glist.go index b049a4a..00f26f4 100644 --- a/glist/glist.go +++ b/glist/glist.go @@ -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) diff --git a/main.go b/main.go index 3105089..f55005f 100644 --- a/main.go +++ b/main.go @@ -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) {