Bladeren bron

refactor: remove unnecessary named function parameters

rigormorrtiss 4 jaren geleden
bovenliggende
commit
28964883ce
6 gewijzigde bestanden met toevoegingen van 9 en 11 verwijderingen
  1. 3 5
      discordo.go
  2. 1 1
      ui/app.go
  3. 1 1
      ui/dropdowns.go
  4. 1 0
      ui/forms.go
  5. 1 3
      ui/inputfields.go
  6. 2 1
      ui/treeviews.go

+ 3 - 5
discordo.go

@@ -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

+ 1 - 1
ui/app.go

@@ -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)

+ 1 - 1
ui/dropdowns.go

@@ -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.

+ 1 - 0
ui/forms.go

@@ -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 - 3
ui/inputfields.go

@@ -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...").

+ 2 - 1
ui/treeviews.go

@@ -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).