Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This aims to increase the efficiency of the code by changing several things. I personally use a provider with a lot of channels, and the application was unusable for me. I decided to dip into the code and see if anything could be changed.
First, I noticed that when categories were being displayed, the flowbox was being rendered for each individual category - there shouldn't be any reason this is required. Rendering everything once at the end is fine. Additionally, a good idea to add onto here would be to freeze the flowbox when adding the groups, and thaw after. That way all rendering is paused until all groups have been compiled. In the worst case, time required to display all groups was 15 seconds. This dropped down to 3 seconds on my computer.
The biggest change was how the search works. Currently, the channel listbox would show all the possible channels, then apply a filter to remove any we don't want. This was wasteful and largely unnecessary, since the required channels would be re-added back to the list if the user filtered by category. Usually when I used to search, I used to search for one specific channel I knew, and it would still try to show all channels, and then filter through them. To remedy this, only the channels that should appear to the user will now be passed to
show_channels
. Filtering this way is greatly better as it avoids looping through all possible channels in the provider. It avoids the need for images for channels that won't even be shows, and it avoids creating a new object while adding it to the listbox. If the user performed another search, we would only have the previous channels shown, so instead now we just redraw the channels that are required.This has hugely improved the speed and performance for me. As I mentioned, I have a provider with a very large number of channels, so searching was the only reasonable way for me to get to where I want. And for each search, looping through all channels was just not feasible. It used to routinely take upwards of 3 to 4 minutes, after which I'd give up. This is now basically instantaneous.
However, I feel the best way forward would be to add a scroll listener and dynamically load channels when they are required.