Commit 538b0ded authored by Black Hat's avatar Black Hat

Show room alias when room name is not available.

parent bc23a94b
......@@ -12,6 +12,7 @@ type Room struct {
controller *Controller
_ string `property:"ID"`
_ string `property:"alias"`
_ string `property:"name"`
_ string `property:"topic"`
_ string `property:"avatar"`
......@@ -19,6 +20,7 @@ type Room struct {
func (r *Room) Init(controller *Controller) {
r.SetController(controller)
r.GetAlias()
r.GetName()
r.GetTopic()
r.GetAvatar()
......@@ -28,6 +30,18 @@ func (r *Room) SetController(controller *Controller) {
r.controller = controller
}
func (r *Room) GetAlias() {
type RespRoomAlias struct {
Alias string `json:"alias"`
}
resp := new(RespRoomAlias)
err := r.controller.matrixCli.StateEvent(r.ID(), "m.room.canonical_alias", "", resp)
if err == nil && resp.Alias != "" {
r.SetAlias(resp.Alias)
return
}
}
func (r *Room) GetName() {
type RespRoomName struct {
Name string `json:"name"`
......
......@@ -110,7 +110,13 @@ func (m *RoomListModel) data(index *core.QModelIndex, role int) *core.QVariant {
return core.NewQVariant14(r.ID())
case Name:
return core.NewQVariant14(r.Name())
if r.Name() != "" {
return core.NewQVariant14(r.Name())
}
if r.Alias() != "" {
return core.NewQVariant14(r.Alias())
}
return core.NewQVariant14(r.ID())
case Topic:
return core.NewQVariant14(r.Topic())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment