As mentioned at https://github.com/aditya-K2/gomp/issues/20#issuecomment-1142443829
The Slow Down was caused due to constant calls to the MPD Server for
playlist info. Using Watcher to handle playlist event changes.
Also when In SearchView upon adding Artist/Album due to constant change
in playlists there was a slow down. Hence using CommandList for that.
Previous Implementation of progressBar wasn't clean and for a long time
I wanted to make progressBar a Primitive. Which also makes it project
agnostic.
Following changes have been made:
1. Moved `utils.GetText` to `ui.GetProgressGlyph` (As it had no use other
than for the progressBar
2. Removed the old Implementation of progressBar
How progressBar works as of right now:
All the Values for the progressBar are provided through the
ProgressFunction()
The ProgressFunction should return
Title (Bar's Title), TopText (Box's Title), BarText (The Text Inside the
progressBar), Percentage(Float64 representing the progress Percentage)
The Algorithm now only inserts the color string over a range i.e
if 1, 2, 3 are matches then instead of adding individually at 1, 2, 3
it adds the color string at 1 and null color string at 3. Also Using
tcell Styles for highlighting the table cells.
Previously During Searching the Connection with mpd client was utilised
to get the title for the files this was slowing the search with large
number of files. Now after adding the Title field to the struct the
Field is accessed instead of querying the server this has lead to faster
searches.
[[ Please Note the Title of a Folder would be the last accessed
track from the FileMap. ]]
Searching the Global Database although is enough but I have felt a need to have a
quick and fast search option to search the current buffer.
Buffer Search is also one of the views It can be only turned on if the File Browser
has focus. ( Thinking of making it global ). The Searching is done
through the fuzzy module. FileNode now implements the Source Interface.
The Changed Function of the Search Bar checks for text changes and then
modifies the Matches Variable which is used by the Update Function to
Draw the Results. The Results have the Matching Characters Highlighted
Differently. Maximum of 15 results are displayed to avoid lag. Upon
Selecting the Result through the Search Bar navigation is possible and
selection of the item is done the same way it works for file Browser.
After Selection the Focus is returned Back to the File Browser. For The
Tracks only the title is used for searching.
Globals are no longer needed instead I am connecting each part with (
what were previously ) globals. Also Renaming SetRenderer to
ConnectRenderer which describes the name more precisely
Previously I was using the InsidePlaylist and InsideSearchView boolean
values which was a very hacky and unscalable way. Instead I am using a
focus map which can be queried to check which view has focus. Also the
Pages Implementation is kind of on hold because it has a lot of problems
for e.g resizing doesn't seem to work as I imagined. I am keeping that
Idea on hold right now.
With the updates in the caching mechanism we check if the file exists in
cache if yes then extractedImagePath now points to that path else
we generate the name for the image and pass the image to extractImage
and it passes the default value if no embedded image was found and
checks in the lastfm api and the rest works the same.
Instead of Caching by maintaining a cache file as mentioned here https://github.com/aditya-K2/goMP/issues/14#issuecomment-989141798
We can directly check if the file exists if it exists then we can just
pass the path to it else we can copy the default image to the path of
the imagePath
This fixes The Issue when a song with unknown duration was played then the percentage was
calculated wrong and the slice was getting out of bound.
fix : I have added a check for the duration.
Sometimes the image is not found and for those artist/albums there is no
way for pointing the image path to default image path so some helper
functions have been added so that we can point them to default Image.