refactor: remove unnecessary named function parameters
This commit is contained in:
parent
2954597ed8
commit
28964883ce
6 changed files with 9 additions and 11 deletions
|
|
@ -21,7 +21,6 @@ var (
|
|||
app *tview.Application
|
||||
loginForm *tview.Form
|
||||
guildsTreeView *tview.TreeView
|
||||
guildsTreeNode *tview.TreeNode
|
||||
messagesTextView *tview.TextView
|
||||
messageInputField *tview.InputField
|
||||
mainFlex *tview.Flex
|
||||
|
|
@ -52,10 +51,9 @@ func main() {
|
|||
config = util.NewConfig()
|
||||
|
||||
app = ui.NewApp(onAppInputCapture)
|
||||
guildsTreeNode = tview.NewTreeNode("")
|
||||
guildsTreeView = ui.NewGuildsTreeView(guildsTreeNode, onGuildsTreeViewSelected, config.Theme)
|
||||
guildsTreeView = ui.NewGuildsTreeView(onGuildsTreeViewSelected, config.Theme)
|
||||
messagesTextView = ui.NewMessagesTextView(app, config.Theme)
|
||||
messageInputField = ui.NewMessageInputField(onMessageInputFieldInputCapture, discordSession, currentChannel, config.Theme)
|
||||
messageInputField = ui.NewMessageInputField(onMessageInputFieldInputCapture, config.Theme)
|
||||
mainFlex = ui.NewMainFlex(guildsTreeView, messagesTextView, messageInputField)
|
||||
|
||||
token := util.GetItem(kr, "token")
|
||||
|
|
@ -151,7 +149,7 @@ func onSessionReady(r *gateway.ReadyEvent) {
|
|||
gNode := tview.NewTreeNode(g.Name).
|
||||
SetReference(g).
|
||||
Collapse()
|
||||
guildsTreeNode.AddChild(gNode)
|
||||
guildsTreeView.GetRoot().AddChild(gNode)
|
||||
|
||||
sort.Slice(g.Channels, func(i, j int) bool {
|
||||
return g.Channels[i].Position < g.Channels[j].Position
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewApp(onAppInputCapture func(event *tcell.EventKey) *tcell.EventKey) *tview.Application {
|
||||
func NewApp(onAppInputCapture func(*tcell.EventKey) *tcell.EventKey) *tview.Application {
|
||||
app := tview.NewApplication().
|
||||
EnableMouse(true).
|
||||
SetInputCapture(onAppInputCapture)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewGuildsDropDown(onGuildsDropDownSelected func(text string, index int), theme *util.Theme) *tview.DropDown {
|
||||
func NewGuildsDropDown(onGuildsDropDownSelected func(string, int), theme *util.Theme) *tview.DropDown {
|
||||
guildsDropDown := tview.NewDropDown()
|
||||
|
||||
guildsDropDown.
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
func NewLoginForm(onLoginFormLoginButtonSelected func()) *tview.Form {
|
||||
f := tview.NewForm()
|
||||
|
||||
f.
|
||||
AddInputField("Email", "", 0, nil, nil).
|
||||
AddPasswordField("Password", "", 0, 0, nil).
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"github.com/diamondburned/arikawa/v3/discord"
|
||||
"github.com/diamondburned/arikawa/v3/session"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/rigormorrtiss/discordo/util"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewMessageInputField(onMessageInputFieldInputCapture func(event *tcell.EventKey) *tcell.EventKey, s *session.Session, c discord.Channel, theme *util.Theme) *tview.InputField {
|
||||
func NewMessageInputField(onMessageInputFieldInputCapture func(*tcell.EventKey) *tcell.EventKey, theme *util.Theme) *tview.InputField {
|
||||
i := tview.NewInputField()
|
||||
i.
|
||||
SetPlaceholder("Message...").
|
||||
|
|
|
|||
|
|
@ -6,8 +6,9 @@ import (
|
|||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
func NewGuildsTreeView(guildsTreeNode *tview.TreeNode, onGuildsTreeViewSelected func(node *tview.TreeNode), theme *util.Theme) *tview.TreeView {
|
||||
func NewGuildsTreeView(onGuildsTreeViewSelected func(*tview.TreeNode), theme *util.Theme) *tview.TreeView {
|
||||
guildsTreeView := tview.NewTreeView()
|
||||
guildsTreeNode := tview.NewTreeNode("")
|
||||
|
||||
guildsTreeView.
|
||||
SetTopLevel(1).
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue