Set as new table if field not available in configuration file (#206)
This commit is contained in:
parent
e7fccffd2e
commit
01c838d8b0
3 changed files with 9 additions and 7 deletions
|
|
@ -50,7 +50,7 @@ func NewCore(cfg *config.Config) *Core {
|
|||
Config: cfg,
|
||||
}
|
||||
|
||||
c.MainFlex.SetInputCapture(c.onInputCapture)
|
||||
c.Application.SetInputCapture(c.onInputCapture)
|
||||
c.GuildsTree = NewGuildsTree(c)
|
||||
c.ChannelsTree = NewChannelsTree(c)
|
||||
c.MessagesPanel = NewMessagesPanel(c)
|
||||
|
|
@ -136,12 +136,12 @@ func (c *Core) onInputCapture(e *tcell.EventKey) *tcell.EventKey {
|
|||
|
||||
keysTable, ok := c.Config.State.GetGlobal("keys").(*lua.LTable)
|
||||
if !ok {
|
||||
return e
|
||||
keysTable = c.Config.State.NewTable()
|
||||
}
|
||||
|
||||
applicationTable, ok := keysTable.RawGetString("application").(*lua.LTable)
|
||||
if !ok {
|
||||
return e
|
||||
applicationTable = c.Config.State.NewTable()
|
||||
}
|
||||
|
||||
var fn lua.LValue
|
||||
|
|
@ -276,6 +276,8 @@ func (c *Core) onStateGuildCreate(g *gateway.GuildCreateEvent) {
|
|||
rootNode := c.GuildsTree.GetRoot()
|
||||
rootNode.AddChild(guildNode)
|
||||
|
||||
c.GuildsTree.SetCurrentNode(rootNode)
|
||||
c.Application.SetFocus(c.GuildsTree)
|
||||
c.Application.Draw()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ func NewMessageInput(c *Core) *MessageInput {
|
|||
func (mi *MessageInput) onInputCapture(e *tcell.EventKey) *tcell.EventKey {
|
||||
keysTable, ok := mi.core.Config.State.GetGlobal("keys").(*lua.LTable)
|
||||
if !ok {
|
||||
return e
|
||||
keysTable = mi.core.Config.State.NewTable()
|
||||
}
|
||||
|
||||
messageInputTable, ok := keysTable.RawGetString("messageInput").(*lua.LTable)
|
||||
if !ok {
|
||||
return e
|
||||
messageInputTable = mi.core.Config.State.NewTable()
|
||||
}
|
||||
|
||||
var fn lua.LValue
|
||||
|
|
|
|||
|
|
@ -53,12 +53,12 @@ func (mp *MessagesPanel) onInputCapture(e *tcell.EventKey) *tcell.EventKey {
|
|||
|
||||
keysTable, ok := mp.core.Config.State.GetGlobal("keys").(*lua.LTable)
|
||||
if !ok {
|
||||
return e
|
||||
keysTable = mp.core.Config.State.NewTable()
|
||||
}
|
||||
|
||||
messagesPanel, ok := keysTable.RawGetString("messagesPanel").(*lua.LTable)
|
||||
if !ok {
|
||||
return e
|
||||
messagesPanel = mp.core.Config.State.NewTable()
|
||||
}
|
||||
|
||||
var fn lua.LValue
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue