Fix some formatting and enable pretty panics in non-debug mode. Closes #265

This commit is contained in:
Tulir Asokan 2021-03-11 22:53:13 +02:00
parent 922223d241
commit 3964b6fd89
6 changed files with 23 additions and 18 deletions

View File

@ -40,6 +40,7 @@ func main() {
debugLevel := strings.ToLower(os.Getenv("DEBUG")) debugLevel := strings.ToLower(os.Getenv("DEBUG"))
if debugLevel != "0" && debugLevel != "f" && debugLevel != "false" { if debugLevel != "0" && debugLevel != "f" && debugLevel != "false" {
debug.WriteLogs = true debug.WriteLogs = true
debug.RecoverPrettyPanic = true
} }
if debugLevel == "1" || debugLevel == "t" || debugLevel == "true" { if debugLevel == "1" || debugLevel == "t" || debugLevel == "true" {
debug.RecoverPrettyPanic = false debug.RecoverPrettyPanic = false
@ -72,6 +73,10 @@ func main() {
os.Exit(3) os.Exit(3)
} }
debug.Print("Config directory:", configDir)
debug.Print("Data directory:", dataDir)
debug.Print("Cache directory:", cacheDir)
debug.Print("Download directory:", downloadDir)
gmx := NewGomuks(MainUIProvider, configDir, dataDir, cacheDir, downloadDir) gmx := NewGomuks(MainUIProvider, configDir, dataDir, cacheDir, downloadDir)

View File

@ -21,6 +21,7 @@ import (
"crypto/tls" "crypto/tls"
"encoding/gob" "encoding/gob"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@ -32,7 +33,6 @@ import (
"runtime" "runtime"
dbg "runtime/debug" dbg "runtime/debug"
"time" "time"
"errors"
"maunium.net/go/mautrix" "maunium.net/go/mautrix"
"maunium.net/go/mautrix/crypto/attachment" "maunium.net/go/mautrix/crypto/attachment"
@ -845,9 +845,9 @@ func (c *Container) PrepareMediaMessage(room *rooms.Room, path string, rel *ifc.
return nil, err return nil, err
} }
content := event.MessageEventContent{ content := event.MessageEventContent{
MsgType: resp.MsgType, MsgType: resp.MsgType,
Body: resp.Name, Body: resp.Name,
Info: resp.Info, Info: resp.Info,
} }
if resp.EncryptionInfo != nil { if resp.EncryptionInfo != nil {
content.File = &event.EncryptedFileInfo{ content.File = &event.EncryptedFileInfo{

View File

@ -247,12 +247,12 @@ func (s *GomuksSyncer) GetFilterJSON(_ id.UserID) *mautrix.Filter {
IncludeLeave: false, IncludeLeave: false,
State: mautrix.FilterPart{ State: mautrix.FilterPart{
LazyLoadMembers: true, LazyLoadMembers: true,
Types: stateEvents, Types: stateEvents,
}, },
Timeline: mautrix.FilterPart{ Timeline: mautrix.FilterPart{
LazyLoadMembers: true, LazyLoadMembers: true,
Types: append(messageEvents, stateEvents...), Types: append(messageEvents, stateEvents...),
Limit: 50, Limit: 50,
}, },
Ephemeral: mautrix.FilterPart{ Ephemeral: mautrix.FilterPart{
Types: []event.Type{event.EphemeralEventTyping, event.EphemeralEventReceipt}, Types: []event.Type{event.EphemeralEventTyping, event.EphemeralEventReceipt},

View File

@ -36,7 +36,7 @@ type FuzzySearchModal struct {
container *mauview.Box container *mauview.Box
search *mauview.InputArea search *mauview.InputArea
results *mauview.TextView results *mauview.TextView
matches fuzzy.Ranks matches fuzzy.Ranks

View File

@ -42,10 +42,10 @@ func NewListEntity(ordered bool, start int, children []Entity) *ListEntity {
entity := &ListEntity{ entity := &ListEntity{
ContainerEntity: &ContainerEntity{ ContainerEntity: &ContainerEntity{
BaseEntity: &BaseEntity{ BaseEntity: &BaseEntity{
Tag: "ul", Tag: "ul",
Block: true, Block: true,
}, },
Indent: 2, Indent: 2,
Children: children, Children: children,
}, },
Ordered: ordered, Ordered: ordered,
@ -66,8 +66,8 @@ func (le *ListEntity) AdjustStyle(fn AdjustStyleFunc) Entity {
func (le *ListEntity) Clone() Entity { func (le *ListEntity) Clone() Entity {
return &ListEntity{ return &ListEntity{
ContainerEntity: le.ContainerEntity.Clone().(*ContainerEntity), ContainerEntity: le.ContainerEntity.Clone().(*ContainerEntity),
Ordered: le.Ordered, Ordered: le.Ordered,
Start: le.Start, Start: le.Start,
} }
} }

View File

@ -34,12 +34,12 @@ import (
var tagOrder = map[string]int{ var tagOrder = map[string]int{
"net.maunium.gomuks.fake.invite": 4, "net.maunium.gomuks.fake.invite": 4,
"m.favourite": 3, "m.favourite": 3,
"net.maunium.gomuks.fake.direct": 2, "net.maunium.gomuks.fake.direct": 2,
"": 1, "": 1,
"m.lowpriority": -1, "m.lowpriority": -1,
"m.server_notice": -2, "m.server_notice": -2,
"net.maunium.gomuks.fake.leave": -3, "net.maunium.gomuks.fake.leave": -3,
} }
// TagNameList is a list of Matrix tag names where default names are sorted in a hardcoded way. // TagNameList is a list of Matrix tag names where default names are sorted in a hardcoded way.