diff options
| author | citrons <citrons@mondecitronne.com> | 2025-06-09 15:20:34 -0500 |
|---|---|---|
| committer | citrons <citrons@mondecitronne.com> | 2025-06-09 15:20:34 -0500 |
| commit | ed7f662431a8e29a4ed27805c174ee72b4a7346a (patch) | |
| tree | 08543381d7ef90a4cf82d0570beb55ca387a786f /client/application.go | |
| parent | cd06a27e20717cdfbcc6840328f67405acc7c9e7 (diff) | |
fix message send in history view
Diffstat (limited to 'client/application.go')
| -rw-r--r-- | client/application.go | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/client/application.go b/client/application.go index f6310b9..9f6a5a1 100644 --- a/client/application.go +++ b/client/application.go @@ -71,17 +71,9 @@ func (a *application) OnDisconnect(err error) { func (a *application) OnEvent(cmd proto.Command) { switch cmd.Kind { case "p": - if len(cmd.Args) == 0 { - break + if len(cmd.Args) > 0 { + a.onPut(cmd.Target, cmd.Args[0]) } - a.windowCache.ForAll(func(win window.Window) { - switch win.(type) { - case *channelWindow: - if win.(*channelWindow).location.id == cmd.Target { - win.(*channelWindow).put(cmd.Args[0]) - } - } - }) case "update": if len(cmd.Args) > 0 { a.onUpdate(cmd.Target, cmd.Args[0]) @@ -96,12 +88,27 @@ func (a *application) OnEvent(cmd proto.Command) { } } +func (a *application) onPut(target string, msg proto.Object) { + a.windowCache.ForAll(func(win window.Window) { + switch win.(type) { + case *channelWindow: + if win.(*channelWindow).location.id == target { + win.(*channelWindow).put(msg) + } + } + }) +} + func (a *application) OnResponse(requestId string, cmd proto.Command) { switch cmd.Kind { case "you-are": if len(cmd.Args) > 0 { a.cmdWindow.info("your name is: %s", cmd.Args[0].Fields[""]) } + case "p": + if len(cmd.Args) > 0 { + a.onPut(cmd.Target, cmd.Args[0]) + } } } |
