reddit-moderator-toolbox icon indicating copy to clipboard operation
reddit-moderator-toolbox copied to clipboard

Fix settings module sorting; clean up TBModule

Open eritbh opened this issue 3 years ago • 1 comments

v6 introduced a regression where the module list in settings would no longer be sorted alphabetically. The .forEach callback which is responsible for adding the module tabs to the DOM was made async, which caused the tabs to be added in no particular order despite being sorted beforehand, since async operations for looking up information about the module can complete out of order.

This change fixes that issue by just making that loop a serial for loop. This does cause some flashing of the module list when opening the settings window, as there are asynchronous operations that occur for each module so they can't be added in the same tick; however, in my opinion it's minor, and implementing it properly would require reworking more of this code than I feel comfortable with.

This also cleans up some legacy features of the module system which were no longer necessary: module.shortname has been replaced with the new module.id across the board, TBModule.modules has been reworked into a simple array of modules rather than an object, and TBModule.moduleList has been removed.

eritbh avatar Oct 17 '22 17:10 eritbh

I just had a look and for me a bunch of modules are missing now

image

This does cause some flashing of the module list when opening the settings window, as there are asynchronous operations that occur for each module so they can't be added in the same tick; however, in my opinion it's minor, and implementing it properly would require reworking more of this code than I feel comfortable with.

Is it possible to somehow detect the last module being loaded? If so, we could start out with the list being hidden and showing it once it has been build.

creesch avatar Oct 22 '22 11:10 creesch

Is it possible to somehow detect the last module being loaded? If so, we could start out with the list being hidden and showing it once it has been build.

I think it should be. I'll look into this and the issue you're having with stuff not showing up.

eritbh avatar Oct 25 '22 02:10 eritbh

I can't immediately reproduce the modules missing thing on my end - really not sure what's going on there. ec0d85e has us wait to display the settings window until it's fully populated with all the modules.

eritbh avatar Nov 17 '22 01:11 eritbh