More small changes to room list
This commit is contained in:
parent
43212996e9
commit
27ecb48e23
@ -91,7 +91,7 @@ func NewRoomList(parent *MainView) *RoomList {
|
|||||||
parent: parent,
|
parent: parent,
|
||||||
|
|
||||||
items: make(map[string]*TagRoomList),
|
items: make(map[string]*TagRoomList),
|
||||||
tags: []string{"m.favourite", "net.maunium.gomuks.fake.direct", "", "m.lowpriority"},
|
tags: []string{},
|
||||||
|
|
||||||
scrollOffset: 0,
|
scrollOffset: 0,
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ func (list *RoomList) checkTag(tag string) {
|
|||||||
trl, ok := list.items[tag]
|
trl, ok := list.items[tag]
|
||||||
|
|
||||||
if ok && trl.IsEmpty() {
|
if ok && trl.IsEmpty() {
|
||||||
//delete(list.items, tag)
|
delete(list.items, tag)
|
||||||
ok = false
|
ok = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ func (list *RoomList) Clear() {
|
|||||||
list.Lock()
|
list.Lock()
|
||||||
defer list.Unlock()
|
defer list.Unlock()
|
||||||
list.items = make(map[string]*TagRoomList)
|
list.items = make(map[string]*TagRoomList)
|
||||||
list.tags = []string{"m.favourite", "net.maunium.gomuks.fake.direct", "", "m.lowpriority"}
|
list.tags = []string{}
|
||||||
for _, tag := range list.tags {
|
for _, tag := range list.tags {
|
||||||
list.items[tag] = NewTagRoomList(list, tag)
|
list.items[tag] = NewTagRoomList(list, tag)
|
||||||
}
|
}
|
||||||
@ -533,7 +533,7 @@ func (list *RoomList) clickRoom(line, column int, mod bool) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var nsRegex = regexp.MustCompile("^[a-z]\\.[a-z](?:\\.[a-z])*$")
|
var nsRegex = regexp.MustCompile("^[a-z]+\\.[a-z]+(?:\\.[a-z]+)*$")
|
||||||
|
|
||||||
func (list *RoomList) GetTagDisplayName(tag string) string {
|
func (list *RoomList) GetTagDisplayName(tag string) string {
|
||||||
switch {
|
switch {
|
||||||
|
@ -170,7 +170,10 @@ func almostEqual(a, b float64) bool {
|
|||||||
// ShouldBeAfter returns if the first room should be after the second room in the room list.
|
// ShouldBeAfter returns if the first room should be after the second room in the room list.
|
||||||
// The manual order and last received message timestamp are considered.
|
// The manual order and last received message timestamp are considered.
|
||||||
func (trl *TagRoomList) ShouldBeAfter(room1 *OrderedRoom, room2 *OrderedRoom) bool {
|
func (trl *TagRoomList) ShouldBeAfter(room1 *OrderedRoom, room2 *OrderedRoom) bool {
|
||||||
return room1.order > room2.order || (almostEqual(room1.order, room2.order) && room2.LastReceivedMessage.After(room1.LastReceivedMessage))
|
// Lower order value = higher in list
|
||||||
|
return room1.order > room2.order ||
|
||||||
|
// Equal order value and more recent message = higher in the list
|
||||||
|
(almostEqual(room1.order, room2.order) && room2.LastReceivedMessage.After(room1.LastReceivedMessage))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (trl *TagRoomList) Insert(order json.Number, mxRoom *rooms.Room) {
|
func (trl *TagRoomList) Insert(order json.Number, mxRoom *rooms.Room) {
|
||||||
|
Loading…
Reference in New Issue
Block a user