Add option to disable typing notifications (#63)
This commit is contained in:
		@@ -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,
 | 
			
		||||
 
 | 
			
		||||
@@ -18,10 +18,10 @@ package ui
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"maunium.net/go/gomuks/debug"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/lucasb-eyer/go-colorful"
 | 
			
		||||
	"maunium.net/go/gomuks/debug"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"unicode"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -74,7 +74,7 @@ func cmdRainbow(cmd *Command) {
 | 
			
		||||
			html.WriteRune(char)
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		color := rainbow.GetInterpolatedColorFor(float64(i)/float64(len(text))).Hex()
 | 
			
		||||
		color := rainbow.GetInterpolatedColorFor(float64(i) / float64(len(text))).Hex()
 | 
			
		||||
		fmt.Fprintf(&html, "<font color=\"%s\">%c</font>", color, char)
 | 
			
		||||
	}
 | 
			
		||||
	tempMessage := cmd.Room.NewTempMessage("m.text", html.String())
 | 
			
		||||
@@ -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()
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -102,10 +102,12 @@ func (view *MainView) MarkRead(roomView *RoomView) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (view *MainView) InputChanged(roomView *RoomView, text string) {
 | 
			
		||||
	if len(text) == 0 {
 | 
			
		||||
		go view.matrix.SendTyping(roomView.Room.ID, false)
 | 
			
		||||
	} else if text[0] != '/' {
 | 
			
		||||
		go view.matrix.SendTyping(roomView.Room.ID, true)
 | 
			
		||||
	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)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user