diff --git a/brclient/appstate.go b/brclient/appstate.go index c24c573c..872cc278 100644 --- a/brclient/appstate.go +++ b/brclient/appstate.go @@ -641,6 +641,18 @@ func (as *appState) activeWindowMsgs() string { return msgs } +// activeChatWindow returns the currently active chat window or nil if the +// active window is _not_ a chat window. +func (as *appState) activeChatWindow() *chatWindow { + var res *chatWindow + as.chatWindowsMtx.Lock() + if as.activeCW >= 0 { + res = as.chatWindows[as.activeCW] + } + as.chatWindowsMtx.Unlock() + return res +} + func (as *appState) rmqLen() int { as.qlenMtx.Lock() l := as.qlen @@ -2649,7 +2661,12 @@ func newAppState(sendMsg func(tea.Msg), lndLogLines *sloglinesbuffer.Buffer, } as.contentMtx.Unlock() - as.repaintIfActive(cw) + activeCW := as.activeChatWindow() + as.sendMsg(msgDownloadCompleted(fid)) + if activeCW != nil && activeCW != cw { + activeCW.newHelpMsg("Download completed: %s", diskPath) + as.repaintIfActive(activeCW) + } }, FileDownloadProgress: func(user *client.RemoteUser, fm rpc.FileMetadata, diff --git a/brclient/mainwindow.go b/brclient/mainwindow.go index ac9a1e3a..e636220e 100644 --- a/brclient/mainwindow.go +++ b/brclient/mainwindow.go @@ -363,6 +363,9 @@ func (mws mainWindowState) Update(msg tea.Msg) (tea.Model, tea.Cmd) { mws.escStr = "" mws.escMode = false + case msgDownloadCompleted: + mws.updateViewportContent() + default: // Handle other messages. mws.textArea, cmd = mws.textArea.Update(msg) diff --git a/brclient/messages.go b/brclient/messages.go index 05950db2..dd46c010 100644 --- a/brclient/messages.go +++ b/brclient/messages.go @@ -6,6 +6,7 @@ import ( "github.com/atotto/clipboard" tea "github.com/charmbracelet/bubbletea" + "github.com/companyzero/bisonrelay/client/clientdb" "github.com/companyzero/bisonrelay/client/clientintf" "github.com/companyzero/bisonrelay/zkidentity" "github.com/decred/dcrd/dcrutil/v4" @@ -63,6 +64,8 @@ type msgShowSharedFilesForLink struct{} type msgProcessEsc struct{} +type msgDownloadCompleted clientdb.FileID + func paste() tea.Msg { str, err := clipboard.ReadAll() if err != nil {