diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-05-04 00:55:28 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-05-04 00:55:30 +0300 |
commit | 122b2441c991a941193769569c532d8b0e198904 (patch) | |
tree | d4a42685edae72bde94b1e20142f90fd66168bec /matrix | |
parent | 93cbdc0ca88d46454b96043d8baf4b231e91474a (diff) |
Add support for explicit ordering and limiting rooms shown under a tag
Fixes #41
Diffstat (limited to 'matrix')
-rw-r--r-- | matrix/matrix.go | 6 | ||||
-rw-r--r-- | matrix/rooms/room.go | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/matrix/matrix.go b/matrix/matrix.go index 341d541..b43a858 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -262,7 +262,11 @@ func (c *Container) HandleTag(source EventSource, evt *gomatrix.Event) { index := 0 for tag, infoifc := range tags { info, _ := infoifc.(map[string]interface{}) - order, _ := info["order"].(float64) + order := "0.5" + rawOrder, ok := info["order"] + if ok { + order = fmt.Sprintf("%v", rawOrder) + } newTags[index] = rooms.RoomTag{ Tag: tag, Order: order, diff --git a/matrix/rooms/room.go b/matrix/rooms/room.go index 808eecb..40303be 100644 --- a/matrix/rooms/room.go +++ b/matrix/rooms/room.go @@ -39,8 +39,8 @@ const ( type RoomTag struct { // The name of the tag. Tag string - // The order of the tag. Smaller values are ordered higher. - Order float64 + // The order of the tag. + Order string } // Room represents a single Matrix room. @@ -118,7 +118,7 @@ func (room *Room) MarkRead() { func (room *Room) Tags() []RoomTag { if len(room.RawTags) == 0 { - return []RoomTag{{"", 0.5}} + return []RoomTag{{"", "0.5"}} } return room.RawTags } |