diff options
author | Grail Finder <wohilas@gmail.com> | 2024-11-20 06:51:40 +0300 |
---|---|---|
committer | Grail Finder <wohilas@gmail.com> | 2024-11-20 06:51:40 +0300 |
commit | aaf056663628f15bb6e4f23c899b6fd31bac5bf7 (patch) | |
tree | a0129fbb531e31d1a9d6465549a44b823906aaae /main.go | |
parent | f32375488f5127c910021f627d83e017c5c7a10f (diff) |
Enha: db chat management
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -60,7 +60,7 @@ func main() { } } chatOpts := []string{"cancel", "new"} - fList, err := listHistoryFiles(historyDir) + fList, err := loadHistoryChats() if err != nil { panic(err) } @@ -74,18 +74,16 @@ func main() { // set chat body chatBody.Messages = defaultStarter textView.SetText(chatToText(showSystemMsgs)) - chatFileLoaded = path.Join(historyDir, fmt.Sprintf("%d_chat.json", time.Now().Unix())) + activeChatName = path.Join(historyDir, fmt.Sprintf("%d_chat.json", time.Now().Unix())) pages.RemovePage("history") return // set text case "cancel": pages.RemovePage("history") - // pages.ShowPage("main") return default: - // fn := path.Join(historyDir, buttonLabel) fn := buttonLabel - history, err := readHistoryChat(fn) + history, err := loadHistoryChat(fn) if err != nil { logger.Error("failed to read history file", "filename", fn) pages.RemovePage("history") @@ -93,7 +91,7 @@ func main() { } chatBody.Messages = history textView.SetText(chatToText(showSystemMsgs)) - chatFileLoaded = fn + activeChatName = fn pages.RemovePage("history") return } @@ -104,14 +102,11 @@ func main() { editArea.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyEscape && editMode { editedMsg := editArea.GetText() - // TODO: trim msg number and icon chatBody.Messages[selectedIndex].Content = editedMsg // change textarea textView.SetText(chatToText(showSystemMsgs)) pages.RemovePage("editArea") editMode = false - // panic("do we get here?") - // pages.ShowPage("main") return nil } return event @@ -151,7 +146,8 @@ func main() { textView.ScrollToEnd() app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyF1 { - fList, err := listHistoryFiles(historyDir) + // fList, err := listHistoryFiles(historyDir) + fList, err := loadHistoryChats() if err != nil { panic(err) } |