Add option to disable typing notifications

This commit is contained in:
Digital 2018-06-29 21:22:19 +02:00
parent c3f30a160f
commit b5b7f8e24f
5 changed files with 30 additions and 20 deletions

View file

@ -32,9 +32,13 @@ or compile from source:
- jump to room - `Alt + Enter`, then `Tab` and `Enter` to navigate and select room
### Commands
* `/quit` - Close gomuks
* `/logout` - Log out, clear caches and go back to the login view
* `/clearcache` - Clear room state cache and close gomuks
* `/leave` - Leave the current room
* `/join <room>` - Join the room with the given room ID or alias
* `/panic` - Trigger a test panic
* `help` - Is a known command
* `me <text>` - Send an emote
* `quit` - Close gomuks
* `clearcache` - Clear room state and close gomuks
* `leave` - Leave the current room
* `join <room>` - Join the room with the given room ID or alias
* `toggle <rooms/users/baremessages/images/typingnotif>` - Change user preferences
* `logout` - Log out, clear caches and go back to the login view
* `send <room id> <event type> <content>` - Send a custom event
* `setstate <room id> <event type> <state key/`-`> <content>` - Change room state

View file

@ -41,6 +41,7 @@ type UserPreferences struct {
HideRoomList bool `yaml:"hide_room_list"`
BareMessageView bool `yaml:"bare_message_view"`
DisableImages bool `yaml:"disable_images"`
DisableTypingNotifs bool `yaml:"disable_typing_notifs"`
}
// Config contains the main config of gomuks.

View file

@ -88,7 +88,7 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
"clearcache": cmdClearCache,
"leave": cmdLeave,
"join": cmdJoin,
"uitoggle": cmdUIToggle,
"toggle": cmdToggle,
"logout": cmdLogout,
"sendevent": cmdSendEvent,
"setstate": cmdSetState,

View file

@ -182,9 +182,9 @@ func cmdSetState(cmd *Command) {
}
}
func cmdUIToggle(cmd *Command) {
func cmdToggle(cmd *Command) {
if len(cmd.Args) == 0 {
cmd.Reply("Usage: /uitoggle <rooms/users/baremessages/images>")
cmd.Reply("Usage: /toggle <rooms/users/baremessages/images/typingnotif>")
return
}
switch cmd.Args[0] {
@ -196,11 +196,14 @@ func cmdUIToggle(cmd *Command) {
cmd.Config.Preferences.BareMessageView = !cmd.Config.Preferences.BareMessageView
case "images":
cmd.Config.Preferences.DisableImages = !cmd.Config.Preferences.DisableImages
case "typingnotif":
cmd.Config.Preferences.DisableTypingNotifs = !cmd.Config.Preferences.DisableTypingNotifs
default:
cmd.Reply("Usage: /uitoggle <rooms/users/baremessages/images>")
cmd.Reply("Usage: /toggle <rooms/users/baremessages/images/typingnotif>")
return
}
cmd.UI.Render()
// is there a reason this is called twice?
// cmd.UI.Render()
cmd.UI.Render()
go cmd.Matrix.SendPreferencesToMatrix()
}

View file

@ -102,12 +102,14 @@ func (view *MainView) MarkRead(roomView *RoomView) {
}
func (view *MainView) InputChanged(roomView *RoomView, text string) {
if !roomView.config.Preferences.DisableTypingNotifs {
if len(text) == 0 {
go view.matrix.SendTyping(roomView.Room.ID, false)
} else if text[0] != '/' {
go view.matrix.SendTyping(roomView.Room.ID, true)
}
}
}
func findWordToTabComplete(text string) string {
output := ""