Gofmt
This commit is contained in:
		@@ -21,13 +21,13 @@ import (
 | 
				
			|||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"gopkg.in/yaml.v2"
 | 
					 | 
				
			||||||
	"maunium.net/go/gomuks/debug"
 | 
					 | 
				
			||||||
	"maunium.net/go/gomuks/matrix/rooms"
 | 
					 | 
				
			||||||
	"maunium.net/go/gomuks/matrix/pushrules"
 | 
					 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
	"strings"
 | 
						"gopkg.in/yaml.v2"
 | 
				
			||||||
	"maunium.net/go/gomatrix"
 | 
						"maunium.net/go/gomatrix"
 | 
				
			||||||
 | 
						"maunium.net/go/gomuks/debug"
 | 
				
			||||||
 | 
						"maunium.net/go/gomuks/matrix/pushrules"
 | 
				
			||||||
 | 
						"maunium.net/go/gomuks/matrix/rooms"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Config contains the main config of gomuks.
 | 
					// Config contains the main config of gomuks.
 | 
				
			||||||
@@ -261,7 +261,7 @@ func (config *Config) SaveRooms() {
 | 
				
			|||||||
	if config.nosave {
 | 
						if config.nosave {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	os.MkdirAll(config.StateDir, 0700)
 | 
						os.MkdirAll(config.StateDir, 0700)
 | 
				
			||||||
	for _, room := range config.Rooms {
 | 
						for _, room := range config.Rooms {
 | 
				
			||||||
		path := config.getRoomCachePath(room)
 | 
							path := config.getRoomCachePath(room)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -337,7 +337,7 @@ func (c *Container) HandleReadReceipt(source EventSource, evt *gomatrix.Event) {
 | 
				
			|||||||
	c.ui.Render()
 | 
						c.ui.Render()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (c *Container) parseDirectChatInfo(evt *gomatrix.Event) (map[*rooms.Room]bool){
 | 
					func (c *Container) parseDirectChatInfo(evt *gomatrix.Event) map[*rooms.Room]bool {
 | 
				
			||||||
	directChats := make(map[*rooms.Room]bool)
 | 
						directChats := make(map[*rooms.Room]bool)
 | 
				
			||||||
	for _, rawRoomIDList := range evt.Content {
 | 
						for _, rawRoomIDList := range evt.Content {
 | 
				
			||||||
		roomIDList, ok := rawRoomIDList.([]interface{})
 | 
							roomIDList, ok := rawRoomIDList.([]interface{})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,16 +17,16 @@
 | 
				
			|||||||
package matrix
 | 
					package matrix
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"testing"
 | 
					 | 
				
			||||||
	"maunium.net/go/gomuks/config"
 | 
					 | 
				
			||||||
	"github.com/stretchr/testify/assert"
 | 
					 | 
				
			||||||
	"net/http"
 | 
					 | 
				
			||||||
	"maunium.net/go/gomatrix"
 | 
					 | 
				
			||||||
	"strings"
 | 
					 | 
				
			||||||
	"fmt"
 | 
					 | 
				
			||||||
	"io/ioutil"
 | 
					 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"github.com/stretchr/testify/assert"
 | 
				
			||||||
 | 
						"io/ioutil"
 | 
				
			||||||
 | 
						"maunium.net/go/gomatrix"
 | 
				
			||||||
 | 
						"maunium.net/go/gomuks/config"
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
						"testing"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestContainer_InitClient_Empty(t *testing.T) {
 | 
					func TestContainer_InitClient_Empty(t *testing.T) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,8 +21,8 @@ import (
 | 
				
			|||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"maunium.net/go/gomuks/lib/glob"
 | 
					 | 
				
			||||||
	"maunium.net/go/gomatrix"
 | 
						"maunium.net/go/gomatrix"
 | 
				
			||||||
 | 
						"maunium.net/go/gomuks/lib/glob"
 | 
				
			||||||
	"maunium.net/go/gomuks/matrix/rooms"
 | 
						"maunium.net/go/gomuks/matrix/rooms"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,9 +17,9 @@
 | 
				
			|||||||
package pushrules
 | 
					package pushrules
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"maunium.net/go/gomuks/lib/glob"
 | 
					 | 
				
			||||||
	"maunium.net/go/gomatrix"
 | 
					 | 
				
			||||||
	"encoding/gob"
 | 
						"encoding/gob"
 | 
				
			||||||
 | 
						"maunium.net/go/gomatrix"
 | 
				
			||||||
 | 
						"maunium.net/go/gomuks/lib/glob"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,9 +17,9 @@
 | 
				
			|||||||
package pushrules_test
 | 
					package pushrules_test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"testing"
 | 
					 | 
				
			||||||
	"maunium.net/go/gomuks/matrix/pushrules"
 | 
					 | 
				
			||||||
	"github.com/stretchr/testify/assert"
 | 
						"github.com/stretchr/testify/assert"
 | 
				
			||||||
 | 
						"maunium.net/go/gomuks/matrix/pushrules"
 | 
				
			||||||
 | 
						"testing"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestPushRuleArray_GetActions_FirstMatchReturns(t *testing.T) {
 | 
					func TestPushRuleArray_GetActions_FirstMatchReturns(t *testing.T) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,17 +17,17 @@
 | 
				
			|||||||
package pushrules_test
 | 
					package pushrules_test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"testing"
 | 
					 | 
				
			||||||
	"github.com/stretchr/testify/assert"
 | 
						"github.com/stretchr/testify/assert"
 | 
				
			||||||
	"maunium.net/go/gomuks/matrix/pushrules"
 | 
						"maunium.net/go/gomuks/matrix/pushrules"
 | 
				
			||||||
 | 
						"testing"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestPushRule_Match_Conditions(t *testing.T) {
 | 
					func TestPushRule_Match_Conditions(t *testing.T) {
 | 
				
			||||||
	cond1 := newMatchPushCondition("content.msgtype", "m.emote")
 | 
						cond1 := newMatchPushCondition("content.msgtype", "m.emote")
 | 
				
			||||||
	cond2 := newMatchPushCondition("content.body", "*pushrules")
 | 
						cond2 := newMatchPushCondition("content.body", "*pushrules")
 | 
				
			||||||
	rule := &pushrules.PushRule{
 | 
						rule := &pushrules.PushRule{
 | 
				
			||||||
		Type: pushrules.OverrideRule,
 | 
							Type:       pushrules.OverrideRule,
 | 
				
			||||||
		Enabled: true,
 | 
							Enabled:    true,
 | 
				
			||||||
		Conditions: []*pushrules.PushCondition{cond1, cond2},
 | 
							Conditions: []*pushrules.PushCondition{cond1, cond2},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -42,8 +42,8 @@ func TestPushRule_Match_Conditions_Disabled(t *testing.T) {
 | 
				
			|||||||
	cond1 := newMatchPushCondition("content.msgtype", "m.emote")
 | 
						cond1 := newMatchPushCondition("content.msgtype", "m.emote")
 | 
				
			||||||
	cond2 := newMatchPushCondition("content.body", "*pushrules")
 | 
						cond2 := newMatchPushCondition("content.body", "*pushrules")
 | 
				
			||||||
	rule := &pushrules.PushRule{
 | 
						rule := &pushrules.PushRule{
 | 
				
			||||||
		Type: pushrules.OverrideRule,
 | 
							Type:       pushrules.OverrideRule,
 | 
				
			||||||
		Enabled: false,
 | 
							Enabled:    false,
 | 
				
			||||||
		Conditions: []*pushrules.PushCondition{cond1, cond2},
 | 
							Conditions: []*pushrules.PushCondition{cond1, cond2},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -58,8 +58,8 @@ func TestPushRule_Match_Conditions_FailIfOneFails(t *testing.T) {
 | 
				
			|||||||
	cond1 := newMatchPushCondition("content.msgtype", "m.emote")
 | 
						cond1 := newMatchPushCondition("content.msgtype", "m.emote")
 | 
				
			||||||
	cond2 := newMatchPushCondition("content.body", "*pushrules")
 | 
						cond2 := newMatchPushCondition("content.body", "*pushrules")
 | 
				
			||||||
	rule := &pushrules.PushRule{
 | 
						rule := &pushrules.PushRule{
 | 
				
			||||||
		Type: pushrules.OverrideRule,
 | 
							Type:       pushrules.OverrideRule,
 | 
				
			||||||
		Enabled: true,
 | 
							Enabled:    true,
 | 
				
			||||||
		Conditions: []*pushrules.PushCondition{cond1, cond2},
 | 
							Conditions: []*pushrules.PushCondition{cond1, cond2},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -72,7 +72,7 @@ func TestPushRule_Match_Conditions_FailIfOneFails(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestPushRule_Match_Content(t *testing.T) {
 | 
					func TestPushRule_Match_Content(t *testing.T) {
 | 
				
			||||||
	rule := &pushrules.PushRule{
 | 
						rule := &pushrules.PushRule{
 | 
				
			||||||
		Type: pushrules.ContentRule,
 | 
							Type:    pushrules.ContentRule,
 | 
				
			||||||
		Enabled: true,
 | 
							Enabled: true,
 | 
				
			||||||
		Pattern: "is testing*",
 | 
							Pattern: "is testing*",
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -86,7 +86,7 @@ func TestPushRule_Match_Content(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestPushRule_Match_Content_Fail(t *testing.T) {
 | 
					func TestPushRule_Match_Content_Fail(t *testing.T) {
 | 
				
			||||||
	rule := &pushrules.PushRule{
 | 
						rule := &pushrules.PushRule{
 | 
				
			||||||
		Type: pushrules.ContentRule,
 | 
							Type:    pushrules.ContentRule,
 | 
				
			||||||
		Enabled: true,
 | 
							Enabled: true,
 | 
				
			||||||
		Pattern: "is testing*",
 | 
							Pattern: "is testing*",
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -100,7 +100,7 @@ func TestPushRule_Match_Content_Fail(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestPushRule_Match_Content_ImplicitGlob(t *testing.T) {
 | 
					func TestPushRule_Match_Content_ImplicitGlob(t *testing.T) {
 | 
				
			||||||
	rule := &pushrules.PushRule{
 | 
						rule := &pushrules.PushRule{
 | 
				
			||||||
		Type: pushrules.ContentRule,
 | 
							Type:    pushrules.ContentRule,
 | 
				
			||||||
		Enabled: true,
 | 
							Enabled: true,
 | 
				
			||||||
		Pattern: "testing",
 | 
							Pattern: "testing",
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -114,7 +114,7 @@ func TestPushRule_Match_Content_ImplicitGlob(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestPushRule_Match_Content_IllegalGlob(t *testing.T) {
 | 
					func TestPushRule_Match_Content_IllegalGlob(t *testing.T) {
 | 
				
			||||||
	rule := &pushrules.PushRule{
 | 
						rule := &pushrules.PushRule{
 | 
				
			||||||
		Type: pushrules.ContentRule,
 | 
							Type:    pushrules.ContentRule,
 | 
				
			||||||
		Enabled: true,
 | 
							Enabled: true,
 | 
				
			||||||
		Pattern: "this is not a valid glo[b",
 | 
							Pattern: "this is not a valid glo[b",
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -128,9 +128,9 @@ func TestPushRule_Match_Content_IllegalGlob(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestPushRule_Match_Room(t *testing.T) {
 | 
					func TestPushRule_Match_Room(t *testing.T) {
 | 
				
			||||||
	rule := &pushrules.PushRule{
 | 
						rule := &pushrules.PushRule{
 | 
				
			||||||
		Type: pushrules.RoomRule,
 | 
							Type:    pushrules.RoomRule,
 | 
				
			||||||
		Enabled: true,
 | 
							Enabled: true,
 | 
				
			||||||
		RuleID: "!fakeroom:maunium.net",
 | 
							RuleID:  "!fakeroom:maunium.net",
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	event := newFakeEvent("m.room.message", map[string]interface{}{})
 | 
						event := newFakeEvent("m.room.message", map[string]interface{}{})
 | 
				
			||||||
@@ -139,21 +139,20 @@ func TestPushRule_Match_Room(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestPushRule_Match_Room_Fail(t *testing.T) {
 | 
					func TestPushRule_Match_Room_Fail(t *testing.T) {
 | 
				
			||||||
	rule := &pushrules.PushRule{
 | 
						rule := &pushrules.PushRule{
 | 
				
			||||||
		Type: pushrules.RoomRule,
 | 
							Type:    pushrules.RoomRule,
 | 
				
			||||||
		Enabled: true,
 | 
							Enabled: true,
 | 
				
			||||||
		RuleID: "!otherroom:maunium.net",
 | 
							RuleID:  "!otherroom:maunium.net",
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	event := newFakeEvent("m.room.message", map[string]interface{}{})
 | 
						event := newFakeEvent("m.room.message", map[string]interface{}{})
 | 
				
			||||||
	assert.False(t, rule.Match(blankTestRoom, event))
 | 
						assert.False(t, rule.Match(blankTestRoom, event))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
func TestPushRule_Match_Sender(t *testing.T) {
 | 
					func TestPushRule_Match_Sender(t *testing.T) {
 | 
				
			||||||
	rule := &pushrules.PushRule{
 | 
						rule := &pushrules.PushRule{
 | 
				
			||||||
		Type: pushrules.SenderRule,
 | 
							Type:    pushrules.SenderRule,
 | 
				
			||||||
		Enabled: true,
 | 
							Enabled: true,
 | 
				
			||||||
		RuleID: "@tulir:maunium.net",
 | 
							RuleID:  "@tulir:maunium.net",
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	event := newFakeEvent("m.room.message", map[string]interface{}{})
 | 
						event := newFakeEvent("m.room.message", map[string]interface{}{})
 | 
				
			||||||
@@ -162,9 +161,9 @@ func TestPushRule_Match_Sender(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestPushRule_Match_Sender_Fail(t *testing.T) {
 | 
					func TestPushRule_Match_Sender_Fail(t *testing.T) {
 | 
				
			||||||
	rule := &pushrules.PushRule{
 | 
						rule := &pushrules.PushRule{
 | 
				
			||||||
		Type: pushrules.RoomRule,
 | 
							Type:    pushrules.RoomRule,
 | 
				
			||||||
		Enabled: true,
 | 
							Enabled: true,
 | 
				
			||||||
		RuleID: "@someone:matrix.org",
 | 
							RuleID:  "@someone:matrix.org",
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	event := newFakeEvent("m.room.message", map[string]interface{}{})
 | 
						event := newFakeEvent("m.room.message", map[string]interface{}{})
 | 
				
			||||||
@@ -173,9 +172,9 @@ func TestPushRule_Match_Sender_Fail(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func TestPushRule_Match_UnknownTypeAlwaysFail(t *testing.T) {
 | 
					func TestPushRule_Match_UnknownTypeAlwaysFail(t *testing.T) {
 | 
				
			||||||
	rule := &pushrules.PushRule{
 | 
						rule := &pushrules.PushRule{
 | 
				
			||||||
		Type: pushrules.PushRuleType("foobar"),
 | 
							Type:    pushrules.PushRuleType("foobar"),
 | 
				
			||||||
		Enabled: true,
 | 
							Enabled: true,
 | 
				
			||||||
		RuleID: "@someone:matrix.org",
 | 
							RuleID:  "@someone:matrix.org",
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	event := newFakeEvent("m.room.message", map[string]interface{}{})
 | 
						event := newFakeEvent("m.room.message", map[string]interface{}{})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,10 +22,10 @@ import (
 | 
				
			|||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"encoding/gob"
 | 
				
			||||||
	"maunium.net/go/gomatrix"
 | 
						"maunium.net/go/gomatrix"
 | 
				
			||||||
	"maunium.net/go/gomuks/debug"
 | 
						"maunium.net/go/gomuks/debug"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"encoding/gob"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
@@ -36,7 +36,7 @@ func init() {
 | 
				
			|||||||
type RoomNameSource int
 | 
					type RoomNameSource int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	ExplicitRoomName       RoomNameSource = iota
 | 
						ExplicitRoomName RoomNameSource = iota
 | 
				
			||||||
	CanonicalAliasRoomName
 | 
						CanonicalAliasRoomName
 | 
				
			||||||
	AliasRoomName
 | 
						AliasRoomName
 | 
				
			||||||
	MemberRoomName
 | 
						MemberRoomName
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,7 +34,7 @@ type SyncerSession interface {
 | 
				
			|||||||
type EventSource int
 | 
					type EventSource int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	EventSourcePresence    EventSource = 1 << iota
 | 
						EventSourcePresence EventSource = 1 << iota
 | 
				
			||||||
	EventSourceJoin
 | 
						EventSourceJoin
 | 
				
			||||||
	EventSourceInvite
 | 
						EventSourceInvite
 | 
				
			||||||
	EventSourceLeave
 | 
						EventSourceLeave
 | 
				
			||||||
@@ -72,10 +72,10 @@ func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (er
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	for roomID, roomData := range res.Rooms.Join {
 | 
						for roomID, roomData := range res.Rooms.Join {
 | 
				
			||||||
		room := s.Session.GetRoom(roomID)
 | 
							room := s.Session.GetRoom(roomID)
 | 
				
			||||||
		s.processSyncEvents(room, roomData.State.Events, EventSourceJoin | EventSourceState, false)
 | 
							s.processSyncEvents(room, roomData.State.Events, EventSourceJoin|EventSourceState, false)
 | 
				
			||||||
		s.processSyncEvents(room, roomData.Timeline.Events, EventSourceJoin | EventSourceTimeline, false)
 | 
							s.processSyncEvents(room, roomData.Timeline.Events, EventSourceJoin|EventSourceTimeline, false)
 | 
				
			||||||
		s.processSyncEvents(room, roomData.Ephemeral.Events, EventSourceJoin | EventSourceEphemeral, false)
 | 
							s.processSyncEvents(room, roomData.Ephemeral.Events, EventSourceJoin|EventSourceEphemeral, false)
 | 
				
			||||||
		s.processSyncEvents(room, roomData.AccountData.Events, EventSourceJoin | EventSourceAccountData, false)
 | 
							s.processSyncEvents(room, roomData.AccountData.Events, EventSourceJoin|EventSourceAccountData, false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if len(room.PrevBatch) == 0 {
 | 
							if len(room.PrevBatch) == 0 {
 | 
				
			||||||
			room.PrevBatch = roomData.Timeline.PrevBatch
 | 
								room.PrevBatch = roomData.Timeline.PrevBatch
 | 
				
			||||||
@@ -84,14 +84,14 @@ func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (er
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	for roomID, roomData := range res.Rooms.Invite {
 | 
						for roomID, roomData := range res.Rooms.Invite {
 | 
				
			||||||
		room := s.Session.GetRoom(roomID)
 | 
							room := s.Session.GetRoom(roomID)
 | 
				
			||||||
		s.processSyncEvents(room, roomData.State.Events, EventSourceInvite | EventSourceState, false)
 | 
							s.processSyncEvents(room, roomData.State.Events, EventSourceInvite|EventSourceState, false)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for roomID, roomData := range res.Rooms.Leave {
 | 
						for roomID, roomData := range res.Rooms.Leave {
 | 
				
			||||||
		room := s.Session.GetRoom(roomID)
 | 
							room := s.Session.GetRoom(roomID)
 | 
				
			||||||
		room.HasLeft = true
 | 
							room.HasLeft = true
 | 
				
			||||||
		s.processSyncEvents(room, roomData.State.Events, EventSourceLeave | EventSourceState, true)
 | 
							s.processSyncEvents(room, roomData.State.Events, EventSourceLeave|EventSourceState, true)
 | 
				
			||||||
		s.processSyncEvents(room, roomData.Timeline.Events, EventSourceLeave | EventSourceTimeline, false)
 | 
							s.processSyncEvents(room, roomData.Timeline.Events, EventSourceLeave|EventSourceTimeline, false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if len(room.PrevBatch) == 0 {
 | 
							if len(room.PrevBatch) == 0 {
 | 
				
			||||||
			room.PrevBatch = roomData.Timeline.PrevBatch
 | 
								room.PrevBatch = roomData.Timeline.PrevBatch
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,17 +22,17 @@ import (
 | 
				
			|||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/evidlo/fuzzysearch/fuzzy"
 | 
						"github.com/evidlo/fuzzysearch/fuzzy"
 | 
				
			||||||
 | 
						"maunium.net/go/gomuks/debug"
 | 
				
			||||||
	"maunium.net/go/gomuks/matrix/rooms"
 | 
						"maunium.net/go/gomuks/matrix/rooms"
 | 
				
			||||||
	"maunium.net/go/gomuks/ui/widget"
 | 
						"maunium.net/go/gomuks/ui/widget"
 | 
				
			||||||
	"maunium.net/go/tview"
 | 
					 | 
				
			||||||
	"maunium.net/go/tcell"
 | 
						"maunium.net/go/tcell"
 | 
				
			||||||
	"maunium.net/go/gomuks/debug"
 | 
						"maunium.net/go/tview"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type FuzzySearchModal struct {
 | 
					type FuzzySearchModal struct {
 | 
				
			||||||
	tview.Primitive
 | 
						tview.Primitive
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	search *tview.InputField
 | 
						search  *tview.InputField
 | 
				
			||||||
	results *tview.TextView
 | 
						results *tview.TextView
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	matches  fuzzy.Ranks
 | 
						matches  fuzzy.Ranks
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,12 +22,12 @@ import (
 | 
				
			|||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"math"
 | 
				
			||||||
	"maunium.net/go/gomuks/debug"
 | 
						"maunium.net/go/gomuks/debug"
 | 
				
			||||||
	"maunium.net/go/gomuks/matrix/rooms"
 | 
						"maunium.net/go/gomuks/matrix/rooms"
 | 
				
			||||||
	"maunium.net/go/gomuks/ui/widget"
 | 
						"maunium.net/go/gomuks/ui/widget"
 | 
				
			||||||
	"maunium.net/go/tcell"
 | 
						"maunium.net/go/tcell"
 | 
				
			||||||
	"maunium.net/go/tview"
 | 
						"maunium.net/go/tview"
 | 
				
			||||||
	"math"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type orderedRoom struct {
 | 
					type orderedRoom struct {
 | 
				
			||||||
@@ -446,7 +446,7 @@ func (list *RoomList) Previous() (string, *rooms.Room) {
 | 
				
			|||||||
	indexInvisible := tagRoomList.Index(list.selected)
 | 
						indexInvisible := tagRoomList.Index(list.selected)
 | 
				
			||||||
	if index == -1 && indexInvisible >= 0 {
 | 
						if index == -1 && indexInvisible >= 0 {
 | 
				
			||||||
		num := tagRoomList.TotalLength() - indexInvisible
 | 
							num := tagRoomList.TotalLength() - indexInvisible
 | 
				
			||||||
		tagRoomList.maxShown = int(math.Ceil(float64(num) / 10.0) * 10.0)
 | 
							tagRoomList.maxShown = int(math.Ceil(float64(num)/10.0) * 10.0)
 | 
				
			||||||
		index = tagRoomList.IndexVisible(list.selected)
 | 
							index = tagRoomList.IndexVisible(list.selected)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -479,7 +479,7 @@ func (list *RoomList) Next() (string, *rooms.Room) {
 | 
				
			|||||||
	indexInvisible := tagRoomList.Index(list.selected)
 | 
						indexInvisible := tagRoomList.Index(list.selected)
 | 
				
			||||||
	if index == -1 && indexInvisible >= 0 {
 | 
						if index == -1 && indexInvisible >= 0 {
 | 
				
			||||||
		num := tagRoomList.TotalLength() - indexInvisible + 1
 | 
							num := tagRoomList.TotalLength() - indexInvisible + 1
 | 
				
			||||||
		tagRoomList.maxShown = int(math.Ceil(float64(num) / 10.0) * 10.0)
 | 
							tagRoomList.maxShown = int(math.Ceil(float64(num)/10.0) * 10.0)
 | 
				
			||||||
		index = tagRoomList.IndexVisible(list.selected)
 | 
							index = tagRoomList.IndexVisible(list.selected)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,8 +17,8 @@
 | 
				
			|||||||
package widget
 | 
					package widget
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"maunium.net/go/tview"
 | 
					 | 
				
			||||||
	"maunium.net/go/tcell"
 | 
						"maunium.net/go/tcell"
 | 
				
			||||||
 | 
						"maunium.net/go/tview"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Center wraps the given tview primitive into a Flex element in order to
 | 
					// Center wraps the given tview primitive into a Flex element in order to
 | 
				
			||||||
@@ -37,15 +37,15 @@ func Center(width, height int, p tview.Primitive) tview.Primitive {
 | 
				
			|||||||
type transparentCenter struct {
 | 
					type transparentCenter struct {
 | 
				
			||||||
	*tview.Box
 | 
						*tview.Box
 | 
				
			||||||
	prefWidth, prefHeight int
 | 
						prefWidth, prefHeight int
 | 
				
			||||||
	p tview.Primitive
 | 
						p                     tview.Primitive
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TransparentCenter(width, height int, p tview.Primitive) tview.Primitive {
 | 
					func TransparentCenter(width, height int, p tview.Primitive) tview.Primitive {
 | 
				
			||||||
	return &transparentCenter{
 | 
						return &transparentCenter{
 | 
				
			||||||
		Box: tview.NewBox(),
 | 
							Box:        tview.NewBox(),
 | 
				
			||||||
		prefWidth: width,
 | 
							prefWidth:  width,
 | 
				
			||||||
		prefHeight: height,
 | 
							prefHeight: height,
 | 
				
			||||||
		p: p,
 | 
							p:          p,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,10 +17,10 @@
 | 
				
			|||||||
package widget
 | 
					package widget
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
	"github.com/mattn/go-runewidth"
 | 
						"github.com/mattn/go-runewidth"
 | 
				
			||||||
	"maunium.net/go/tcell"
 | 
						"maunium.net/go/tcell"
 | 
				
			||||||
	"maunium.net/go/tview"
 | 
						"maunium.net/go/tview"
 | 
				
			||||||
	"fmt"
 | 
					 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user