Support changing the server name by clicking it in the status tab

This commit is contained in:
Ken-Håvard Lieng 2017-06-12 06:18:32 +02:00
parent 3b33957161
commit b639ba6846
14 changed files with 259 additions and 56 deletions

View file

@ -178,6 +178,25 @@ func (u *User) SetNick(nick, address string) {
})
}
func (u *User) SetServerName(name, address string) {
db.Batch(func(tx *bolt.Tx) error {
b := tx.Bucket(bucketServers)
id := u.serverID(address)
server := Server{}
v := b.Get(id)
if v != nil {
server.Unmarshal(v)
server.Name = name
data, _ := server.Marshal(nil)
b.Put(id, data)
}
return nil
})
}
func (u *User) RemoveServer(address string) {
db.Batch(func(tx *bolt.Tx) error {
serverID := u.serverID(address)

View file

@ -63,6 +63,9 @@ func TestUser(t *testing.T) {
user.SetNick("bob", srv.Host)
assert.Equal(t, "bob", user.GetServers()[0].Nick)
user.SetServerName("cake", srv.Host)
assert.Equal(t, "cake", user.GetServers()[0].Name)
user.RemoveChannel(srv.Host, chan1.Name)
channels = user.GetChannels()
assert.Len(t, channels, 1)