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