Fixes: Nil Reference when Sending Notifications
Also Handling illegal presses in specific Views (PlaylistView, Searchview)
This commit is contained in:
parent
ff74bf02ba
commit
49c691e04e
Binary file not shown.
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ gomp
|
||||
.idea
|
||||
*.jpg
|
||||
e.go
|
||||
.fuse*
|
||||
|
43
main.go
43
main.go
@ -92,8 +92,8 @@ func main() {
|
||||
// Used for Fuzzy Searching
|
||||
ArtistTreeContent := utils.ConvertToArray(ArtistTree)
|
||||
|
||||
Notify := notify.NewNotificationServer()
|
||||
Notify.Start()
|
||||
globals.Notify = notify.NewNotificationServer()
|
||||
globals.Notify.Start()
|
||||
|
||||
if c, err := CONN.CurrentSong(); err != nil {
|
||||
utils.Print("RED", "Could Not Retrieve the Current Song\n")
|
||||
@ -107,8 +107,8 @@ func main() {
|
||||
}
|
||||
|
||||
// Connecting Notification Server to Client and Rendering Module so that they can send Notifications
|
||||
client.SetNotificationServer(Notify)
|
||||
render.SetNotificationServer(Notify)
|
||||
client.SetNotificationServer(globals.Notify)
|
||||
render.SetNotificationServer(globals.Notify)
|
||||
|
||||
// This Function Is Responsible for Changing the Focus it uses the Focus Map and Based on it Chooses
|
||||
// the Draw Function
|
||||
@ -127,7 +127,7 @@ func main() {
|
||||
},
|
||||
"togglePlayBack": func() {
|
||||
if err := client.TogglePlayBack(); err != nil {
|
||||
Notify.Send("Could not Toggle Play Back")
|
||||
globals.Notify.Send("Could not Toggle Play Back")
|
||||
}
|
||||
},
|
||||
"showParentContent": func() {
|
||||
@ -135,19 +135,19 @@ func main() {
|
||||
},
|
||||
"nextSong": func() {
|
||||
if err := CONN.Next(); err != nil {
|
||||
Notify.Send("Could not Select the Next Song")
|
||||
globals.Notify.Send("Could not Select the Next Song")
|
||||
}
|
||||
},
|
||||
"clearPlaylist": func() {
|
||||
if err := CONN.Clear(); err != nil {
|
||||
Notify.Send("Could not Clear the Playlist")
|
||||
globals.Notify.Send("Could not Clear the Playlist")
|
||||
} else {
|
||||
Notify.Send("Playlist Cleared")
|
||||
globals.Notify.Send("Playlist Cleared")
|
||||
}
|
||||
},
|
||||
"previousSong": func() {
|
||||
if err := CONN.Previous(); err != nil {
|
||||
Notify.Send("Could Not Select the Previous Song")
|
||||
globals.Notify.Send("Could Not Select the Previous Song")
|
||||
}
|
||||
},
|
||||
"addToPlaylist": func() {
|
||||
@ -170,7 +170,7 @@ func main() {
|
||||
Volume -= 10
|
||||
}
|
||||
if err := CONN.SetVolume(int(Volume)); err != nil {
|
||||
Notify.Send("Could Not Decrease the Volume")
|
||||
globals.Notify.Send("Could Not Decrease the Volume")
|
||||
}
|
||||
},
|
||||
"increaseVolume": func() {
|
||||
@ -180,7 +180,7 @@ func main() {
|
||||
Volume += 10
|
||||
}
|
||||
if err := CONN.SetVolume(int(Volume)); err != nil {
|
||||
Notify.Send("Could Not Increase the Volume")
|
||||
globals.Notify.Send("Could Not Increase the Volume")
|
||||
}
|
||||
},
|
||||
"navigateToFiles": func() {
|
||||
@ -206,17 +206,17 @@ func main() {
|
||||
},
|
||||
"stop": func() {
|
||||
if err := CONN.Stop(); err != nil {
|
||||
Notify.Send("Could not Stop the Playback")
|
||||
globals.Notify.Send("Could not Stop the Playback")
|
||||
} else {
|
||||
Notify.Send("Playback Stopped")
|
||||
globals.Notify.Send("Playback Stopped")
|
||||
}
|
||||
},
|
||||
"updateDB": func() {
|
||||
_, err = CONN.Update("")
|
||||
if err != nil {
|
||||
Notify.Send("Could Not Update the Database")
|
||||
globals.Notify.Send("Could Not Update the Database")
|
||||
} else {
|
||||
Notify.Send("Database Updated")
|
||||
globals.Notify.Send("Database Updated")
|
||||
}
|
||||
},
|
||||
"deleteSongFromPlaylist": func() {
|
||||
@ -265,14 +265,21 @@ func main() {
|
||||
if views.GetCurrentView().GetViewName() == "PlaylistView" {
|
||||
if e.Rune() == 'j' || e.Rune() == 'k' {
|
||||
if p, err := CONN.PlaylistInfo(-1, -1); err != nil {
|
||||
Notify.Send("Error Getting PlaylistInfo")
|
||||
globals.Notify.Send("Error Getting PlaylistInfo")
|
||||
} else {
|
||||
if len(p) == 0 {
|
||||
Notify.Send("Empty Playlist")
|
||||
globals.Notify.Send("Empty Playlist")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if views.GetCurrentView().GetViewName() == "SearchView" {
|
||||
if e.Rune() == 'j' || e.Rune() == 'k' {
|
||||
if globals.SearchContentSlice == nil || len(globals.SearchContentSlice) == 0 {
|
||||
globals.Notify.Send("No Search Results")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return e
|
||||
}
|
||||
@ -288,7 +295,7 @@ func main() {
|
||||
globals.SearchContentSlice = nil
|
||||
globals.SearchContentSlice, err = client.GenerateContentSlice(globals.Ui.SearchBar.GetText())
|
||||
if err != nil {
|
||||
Notify.Send("Could Not Retrieve the Results")
|
||||
globals.Notify.Send("Could Not Retrieve the Results")
|
||||
} else {
|
||||
globals.Ui.SearchBar.SetText("")
|
||||
globals.Ui.App.SetFocus(globals.Ui.ExpandedView)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package views
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/aditya-K2/gomp/client"
|
||||
@ -20,12 +19,15 @@ func (s SearchView) GetViewName() string {
|
||||
func (s SearchView) ShowChildrenContent() {
|
||||
UI := globals.Ui
|
||||
SearchContentSlice := globals.SearchContentSlice
|
||||
if len(globals.SearchContentSlice) <= 0 || globals.SearchContentSlice == nil {
|
||||
globals.Notify.Send("No Search Results")
|
||||
} else {
|
||||
r, _ := UI.ExpandedView.GetSelection()
|
||||
client.AddToPlaylist(SearchContentSlice[r], true)
|
||||
}
|
||||
}
|
||||
|
||||
func (s SearchView) ShowParentContent() {
|
||||
fmt.Println(s)
|
||||
globals.Notify.Send("Not Allowed in this View")
|
||||
return
|
||||
}
|
||||
@ -33,9 +35,13 @@ func (s SearchView) ShowParentContent() {
|
||||
func (s SearchView) AddToPlaylist() {
|
||||
UI := globals.Ui
|
||||
SearchContentSlice := globals.SearchContentSlice
|
||||
if len(globals.SearchContentSlice) <= 0 || globals.SearchContentSlice == nil {
|
||||
globals.Notify.Send("No Search Results")
|
||||
} else {
|
||||
r, _ := UI.ExpandedView.GetSelection()
|
||||
client.AddToPlaylist(SearchContentSlice[r], false)
|
||||
}
|
||||
}
|
||||
|
||||
func (p SearchView) Quit() {
|
||||
globals.Ui.App.Stop()
|
||||
|
Loading…
Reference in New Issue
Block a user