Skip to content

Commit 4547774

Browse files
committed
refactor: User.SetColorIdx -> User.setColorIdx, preparing to abstract user
1 parent 33d7d26 commit 4547774

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

chat/message/user.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func NewUser(identity Identifier) *User {
4444
done: make(chan struct{}),
4545
Ignored: set.New(),
4646
}
47-
u.SetColorIdx(rand.Int())
47+
u.setColorIdx(rand.Int())
4848

4949
return &u
5050
}
@@ -59,7 +59,7 @@ func NewUserScreen(identity Identifier, screen io.WriteCloser) *User {
5959
// Rename the user with a new Identifier.
6060
func (u *User) SetID(id string) {
6161
u.Identifier.SetID(id)
62-
u.SetColorIdx(rand.Int())
62+
u.setColorIdx(rand.Int())
6363
}
6464

6565
// ReplyTo returns the last user that messaged this user.
@@ -83,9 +83,9 @@ func (u *User) ToggleQuietMode() {
8383
u.Config.Quiet = !u.Config.Quiet
8484
}
8585

86-
// SetColorIdx will set the colorIdx to a specific value, primarily used for
86+
// setColorIdx will set the colorIdx to a specific value, primarily used for
8787
// testing.
88-
func (u *User) SetColorIdx(idx int) {
88+
func (u *User) setColorIdx(idx int) {
8989
u.colorIdx = idx
9090
}
9191

chat/room.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ func (r *Room) HandleMsg(m message.Message) {
106106
}
107107

108108
if skip && skipUser == user {
109-
// Skip
109+
// Skip self
110110
return
111111
}
112112
if _, ok := m.(*message.AnnounceMsg); ok {
113113
if user.Config.Quiet {
114-
// Skip
114+
// Skip announcements
115115
return
116116
}
117117
}

host_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ func TestHostGetPrompt(t *testing.T) {
2828
var expected, actual string
2929

3030
u := message.NewUser(&Identity{id: "foo"})
31-
u.SetColorIdx(2)
3231

3332
actual = GetPrompt(u)
3433
expected = "[foo] "
@@ -38,7 +37,7 @@ func TestHostGetPrompt(t *testing.T) {
3837

3938
u.Config.Theme = &message.Themes[0]
4039
actual = GetPrompt(u)
41-
expected = "[\033[38;05;3mfoo\033[0m] "
40+
expected = "[\033[38;05;88mfoo\033[0m] "
4241
if actual != expected {
4342
t.Errorf("Got: %q; Expected: %q", actual, expected)
4443
}

0 commit comments

Comments
 (0)