summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcitrons <citrons@mondecitronne.com>2025-06-02 09:19:23 -0500
committercitrons <citrons@mondecitronne.com>2025-06-02 09:19:23 -0500
commitcd33ad54372bd53842fd6e04dbb2859f9ab59f51 (patch)
tree459410c9215a22df29f63de33ad7ec2b373db172
parentf14c0aa7a0ad19065d87424b3abc0fdabd9fe9bb (diff)
refactor join/leave messages`
-rw-r--r--client/channel_window.go56
-rw-r--r--server/channel/channel.go4
2 files changed, 30 insertions, 30 deletions
diff --git a/client/channel_window.go b/client/channel_window.go
index d003ce8..e5b50c3 100644
--- a/client/channel_window.go
+++ b/client/channel_window.go
@@ -238,7 +238,7 @@ func (cw *channelWindow) ShowStatusLine() {
}
func (m channelMsg) Id() string {
- return m.Object.Id
+ return "buffer." + m.Object.Id
}
func (m channelMsg) showDate(bg int32) {
@@ -251,49 +251,49 @@ func (m channelMsg) showDate(bg int32) {
tui.Pop()
}
+func (m channelMsg) showName(bg int32) {
+ nameStyle := tui.Style {Bg: bg, Fg: tui.White}
+ if m.Fields["f"] == globalApp.uid {
+ nameStyle.Fg = tui.Cyan
+ }
+ if m.window.isGone(m.Fields["f"]) {
+ nameStyle.Italic = true
+ } else {
+ nameStyle.Bold = true
+ }
+ tui.Push(m.Id() + ".name", tui.Box {
+ Width: tui.TextSize, Height: 1, NoWrap: true,
+ })
+ tui.Text(m.window.username(m.Fields["f"]), &nameStyle)
+ tui.Pop()
+}
+
func (m channelMsg) Show(odd bool) {
var bg int32 = colorDefault[odd]
+
switch m.Kind {
- case "join":
+ case "join", "leave":
tui.Push("", tui.Box {
Width: tui.Fill, Height: tui.Children, Dir: tui.Left,
})
m.showDate(bg)
- tui.Push("", tui.Box {Width: tui.TextSize, Height: tui.TextSize})
- tui.Text("-> ", &tui.Style {Fg: tui.BrightBlack, Bg: bg})
- tui.Text("join", &tui.Style {Fg: tui.Blue, Bg: bg, Bold: true})
- tui.Text(": ", &tui.Style {Fg: tui.BrightBlack, Bg: bg})
- tui.Text(m.window.username(m.Fields[""]), nil)
- tui.Pop()
- tui.Pop()
- case "leave":
+
+ tui.Push("", tui.Box {Width: tui.Children, Height: 1, Dir: tui.Right})
tui.Push("", tui.Box {
- Width: tui.Fill, Height: tui.Children, Dir: tui.Left,
+ Width: tui.TextSize, Height: tui.TextSize, NoWrap: true,
})
- m.showDate(bg)
- tui.Push("", tui.Box {Width: tui.TextSize, Height: tui.TextSize})
tui.Text("<- ", &tui.Style {Fg: tui.BrightBlack, Bg: bg})
- tui.Text("leave", &tui.Style {Fg: tui.Blue, Bg: bg, Bold: true})
+ tui.Text(m.Kind, &tui.Style {Fg: tui.Blue, Bg: bg})
tui.Text(": ", &tui.Style {Fg: tui.BrightBlack, Bg: bg})
- tui.Text(m.window.username(m.Fields[""]), nil)
tui.Pop()
+ m.showName(bg)
tui.Pop()
- case "m":
- nameStyle := tui.Style {Bg: bg, Fg: tui.White}
- if m.Fields["f"] == globalApp.uid {
- nameStyle.Fg = tui.Cyan
- }
- if m.window.isGone(m.Fields["f"]) {
- nameStyle.Italic = true
- } else {
- nameStyle.Bold = true
- }
+ tui.Pop()
+ case "m":
tui.Push("", tui.Box {Width: tui.Fill, Height: 1, Dir: tui.Left})
m.showDate(bg)
- tui.Push("", tui.Box {Width: tui.TextSize, Height: 1, NoWrap: true})
- tui.Text(m.window.username(m.Fields["f"]), &nameStyle)
- tui.Pop()
+ m.showName(bg)
tui.Pop()
tui.Push("", tui.Box {
diff --git a/server/channel/channel.go b/server/channel/channel.go
index 078e377..449375b 100644
--- a/server/channel/channel.go
+++ b/server/channel/channel.go
@@ -123,7 +123,7 @@ func (c *Channel) Join(u *user.User) *proto.Fail {
}
c.members[u.Id()] = c.defaultMembership
u.Channels[c.id] = true
- c.Put(proto.Object{"join", "", map[string]string {"": u.Id()}})
+ c.Put(proto.Object{"join", "", map[string]string {"f": u.Id()}})
return nil
}
@@ -133,7 +133,7 @@ func (c *Channel) Leave(u *user.User) *proto.Fail {
}
delete(c.members, u.Id())
delete(u.Channels, c.id)
- c.Put(proto.Object{"leave", "", map[string]string {"": u.Id()}})
+ c.Put(proto.Object{"leave", "", map[string]string {"f": u.Id()}})
return nil
}