diff options
| author | raven <citrons@mondecitronne.com> | 2026-02-17 15:21:17 -0600 |
|---|---|---|
| committer | raven <citrons@mondecitronne.com> | 2026-02-17 15:22:10 -0600 |
| commit | 86df926a15da7c5447788b00a34995e0512bd286 (patch) | |
| tree | 13249c0cc6c323ad91ebfc32bffec65a915da23c /client/application.go | |
| parent | 61ba037f8a70d6a842853b9f0f0b782873e0a763 (diff) | |
direct message list
Diffstat (limited to 'client/application.go')
| -rw-r--r-- | client/application.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/client/application.go b/client/application.go index 6f7e599..304869d 100644 --- a/client/application.go +++ b/client/application.go @@ -21,6 +21,8 @@ type application struct { windowHist []window.Location channelList channelList channelScroll tui.ScrollState + dmList channelList + dmScroll tui.ScrollState redraw bool cmdWindow cmdWindow prompts []window.Prompt @@ -104,8 +106,18 @@ func (a *application) OnEvent(cmd proto.Command) { }) case "unread": a.channelList.setUnread(channelLocation {id: cmd.Target}, true) + a.cache.Fetch(cmd.Target, func(ch *proto.Object) { + if ch == nil || ch.Kind != "direct-channel" { + return + } + if !a.dmList.contains(channelLocation {id: cmd.Target}) { + a.newDirect(*ch) + } + a.dmList.setUnread(channelLocation {id: cmd.Target}, true) + }) case "read": a.channelList.setUnread(channelLocation {id: cmd.Target}, false) + a.dmList.setUnread(channelLocation {id: cmd.Target}, false) } } @@ -287,6 +299,13 @@ func (a *application) onAuth(uid string) { } } }) + a.Request(proto.NewCmd("direct-channels", ""), + func(response proto.Command) { + if response.Kind == "direct-channels" { + a.dmList.setChannels(response.Args) + } + }, + ) if !a.welcomed { a.cmdWindow.info("welcome! type /help for help. try: /join talk") a.welcomed = true @@ -395,6 +414,11 @@ func (a *application) newChannel(ch proto.Object) { a.channelScroll.Set(0) } +func (a *application) newDirect(ch proto.Object) { + a.dmList.add(ch.Fields[""], channelLocation {id: ch.Id}) + a.dmScroll.Set(0) +} + func (a *application) getNick() string { if !a.authenticated { return "" |
