Add support for editing room tags
This commit is contained in:
parent
6eaee84465
commit
7f917f0271
2
go.mod
2
go.mod
@ -25,7 +25,7 @@ require (
|
||||
gopkg.in/russross/blackfriday.v2 v2.0.1
|
||||
gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2
|
||||
gopkg.in/yaml.v2 v2.2.2
|
||||
maunium.net/go/mautrix v0.1.0-alpha.3.0.20190616140407-62f6f484857e
|
||||
maunium.net/go/mautrix v0.1.0-alpha.3.0.20190616163219-6b4bce05f314
|
||||
maunium.net/go/mauview v0.0.0-20190606152754-de9e0a754a5d
|
||||
maunium.net/go/tcell v0.0.0-20190606152714-9a88fc07b3ed
|
||||
)
|
||||
|
2
go.sum
2
go.sum
@ -96,6 +96,8 @@ maunium.net/go/mautrix v0.1.0-alpha.3.0.20190616122434-35971ee5ad3c h1:FxaOZhImK
|
||||
maunium.net/go/mautrix v0.1.0-alpha.3.0.20190616122434-35971ee5ad3c/go.mod h1:O+QWJP3H7BZEzIBSrECKpnpRnEKBwaoWVEu/yZwVwxg=
|
||||
maunium.net/go/mautrix v0.1.0-alpha.3.0.20190616140407-62f6f484857e h1:W3NG02SHY4ldbLFyr0vQugKJQdONOb1lEjBPd3PTCrk=
|
||||
maunium.net/go/mautrix v0.1.0-alpha.3.0.20190616140407-62f6f484857e/go.mod h1:O+QWJP3H7BZEzIBSrECKpnpRnEKBwaoWVEu/yZwVwxg=
|
||||
maunium.net/go/mautrix v0.1.0-alpha.3.0.20190616163219-6b4bce05f314 h1:wGlIqs/L+ErBbAHbkpM4AlFi+9+z9Bsle4xD4Gw+y3k=
|
||||
maunium.net/go/mautrix v0.1.0-alpha.3.0.20190616163219-6b4bce05f314/go.mod h1:O+QWJP3H7BZEzIBSrECKpnpRnEKBwaoWVEu/yZwVwxg=
|
||||
maunium.net/go/mauview v0.0.0-20190606152754-de9e0a754a5d h1:H4wZ4vMVnOh5QFsb4xZtssgpv3DDEkBRzQ8iyEg2fX0=
|
||||
maunium.net/go/mauview v0.0.0-20190606152754-de9e0a754a5d/go.mod h1:GL+akv58wNFzzX4IKLvryKx0F/AcYKHql35DiBzBc/w=
|
||||
maunium.net/go/tcell v0.0.0-20190606152714-9a88fc07b3ed h1:sAcUrUZG2LFWBTkTtLKPQvHPHFM5d6huAhr5ZZuxtbQ=
|
||||
|
@ -214,6 +214,7 @@ func (s *GomuksSyncer) GetFilterJSON(userID string) json.RawMessage {
|
||||
Timeline: mautrix.FilterPart{
|
||||
Types: []string{
|
||||
"m.room.message",
|
||||
"m.room.redaction",
|
||||
"m.room.encrypted",
|
||||
"m.sticker",
|
||||
"m.reaction",
|
||||
|
@ -111,6 +111,9 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
|
||||
"rainbow": cmdRainbow,
|
||||
"rainbowme": cmdRainbowMe,
|
||||
"notice": cmdNotice,
|
||||
"tags": cmdTags,
|
||||
"tag": cmdTag,
|
||||
"untag": cmdUntag,
|
||||
"invite": cmdInvite,
|
||||
"hprof": cmdHeapProfile,
|
||||
"cprof": cmdCPUProfile,
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"os"
|
||||
"runtime"
|
||||
dbg "runtime/debug"
|
||||
@ -105,6 +106,59 @@ func cmdNotice(cmd *Command) {
|
||||
cmd.UI.Render()
|
||||
}
|
||||
|
||||
func cmdTags(cmd *Command) {
|
||||
tags := cmd.Room.MxRoom().RawTags
|
||||
if len(tags) == 0 {
|
||||
if cmd.Room.MxRoom().IsDirect {
|
||||
cmd.Reply("This room has no tags, but it's marked as a direct chat.")
|
||||
} else {
|
||||
cmd.Reply("This room has no tags.")
|
||||
}
|
||||
return
|
||||
}
|
||||
var resp strings.Builder
|
||||
resp.WriteString("Tags in this room:\n")
|
||||
for _, tag := range tags {
|
||||
if tag.Order != "" {
|
||||
_, _ = fmt.Fprintf(&resp, "%s (order: %s)\n", tag.Tag, tag.Order)
|
||||
} else {
|
||||
_, _ = fmt.Fprintf(&resp, "%s (no order)\n", tag.Tag)
|
||||
}
|
||||
}
|
||||
cmd.Reply(strings.TrimSpace(resp.String()))
|
||||
}
|
||||
|
||||
func cmdTag(cmd *Command) {
|
||||
if len(cmd.Args) == 0 {
|
||||
cmd.Reply("Usage: /tag <tag> [order]")
|
||||
return
|
||||
}
|
||||
order := math.NaN()
|
||||
if len(cmd.Args) > 1 {
|
||||
var err error
|
||||
order, err = strconv.ParseFloat(cmd.Args[1], 64)
|
||||
if err != nil {
|
||||
cmd.Reply("%s is not a valid order: %v", cmd.Args[1], err)
|
||||
return
|
||||
}
|
||||
}
|
||||
err := cmd.Matrix.Client().AddTag(cmd.Room.MxRoom().ID, cmd.Args[0], order)
|
||||
if err != nil {
|
||||
cmd.Reply("Failed to add tag:", err)
|
||||
}
|
||||
}
|
||||
|
||||
func cmdUntag(cmd *Command) {
|
||||
if len(cmd.Args) == 0 {
|
||||
cmd.Reply("Usage: /untag <tag>")
|
||||
return
|
||||
}
|
||||
err := cmd.Matrix.Client().RemoveTag(cmd.Room.MxRoom().ID, cmd.Args[0])
|
||||
if err != nil {
|
||||
cmd.Reply("Failed to remove tag:", err)
|
||||
}
|
||||
}
|
||||
|
||||
func cmdRoomNick(cmd *Command) {
|
||||
room := cmd.Room.MxRoom()
|
||||
member := room.GetMember(room.SessionUserID)
|
||||
|
@ -370,8 +370,13 @@ func (view *MainView) UpdateTags(room *rooms.Room) {
|
||||
if !view.roomList.Contains(room.ID) {
|
||||
return
|
||||
}
|
||||
reselect := view.roomList.selected == room
|
||||
view.roomList.Remove(room)
|
||||
view.roomList.Add(room)
|
||||
if reselect {
|
||||
view.roomList.SetSelected(room.Tags()[0].Tag, room)
|
||||
}
|
||||
view.parent.Render()
|
||||
}
|
||||
|
||||
func (view *MainView) SetTyping(roomID string, users []string) {
|
||||
|
Loading…
Reference in New Issue
Block a user