Add room name to topic bar if room list is hidden. Closes #317

This commit is contained in:
Tulir Asokan 2022-03-06 22:34:24 +02:00
parent 073739b79b
commit 686f7025cb
2 changed files with 14 additions and 1 deletions

View File

@ -845,6 +845,10 @@ func cmdToggle(cmd *Command) {
*val = !(*val)
debug.Print(thing, *val)
cmd.Reply(toggleMsg[thing].Format(*val))
if thing == "rooms" {
// Update topic string to include or not include room name
cmd.Room.Update()
}
}
cmd.UI.Render()
go cmd.Matrix.SendPreferencesToMatrix()

View File

@ -836,7 +836,16 @@ func (view *RoomView) MxRoom() *rooms.Room {
}
func (view *RoomView) Update() {
view.topic.SetText(strings.Replace(view.Room.GetTopic(), "\n", " ", -1))
topicStr := strings.TrimSpace(strings.ReplaceAll(view.Room.GetTopic(), "\n", " "))
if view.config.Preferences.HideRoomList {
if len(topicStr) > 0 {
topicStr = fmt.Sprintf("%s - %s", view.Room.GetTitle(), topicStr)
} else {
topicStr = view.Room.GetTitle()
}
topicStr = strings.TrimSpace(topicStr)
}
view.topic.SetText(topicStr)
if !view.userListLoaded {
view.UpdateUserList()
}