-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mode state management issue in the main screen #83
Comments
@harchani-ritik Probably yes because the switch is actually present in the main screen, so we only need to refresh the main screen and the torrents list on toggle switch. Rest of the widgets can use Provider when they come in focus. Actually after more research, I realised why do we even need a Consumer in the main screen. Let's try to analyse - There are three providers - Api, GeneralFeatures and Mode *(Api does not even extend ChangeNotifierProvider) 'api.username' '_getAccountsList(api, modeTheme, general)' in Drawer
Now the GeneralFeatures - It is used inside Drawer '_getAccountsList(api, modeTheme, general)' 'general.filterTileList' and 'general.listOfLabels' 'general.pageController' 'general.pageController.jumpToPage(index)' Only the HomePage needs to be inside Consumer of GeneralFeatures because it has TorrentLists which is already inside a Consumer. I tried debugging using a simple FUN FACT - I tried removing all the three Consumer in the root of the MainScreen and the app was working all fine with all updates in the torrent list, account change, account deletion, list sort, mode change, etc. |
Nice @rj-since-2000👏🏻. So you can replace all "consumer" usages with "Provider" wherever necessary and properly test all the functionalities once from your side too before pushing the changes. |
The consumer of
Mode
is at the root of the Scaffold tree in the main_screen.dart which causes the entire tree to rebuild on switching from dark to light mode and vice versa, which is unnecessary and causes a bad user experience. Mode change should only affect the UI and not the business logic!@harchani-ritik I propose to resolve this issue with
provider<Mode>
instead ofconsumer<Mode>
so that only the UI is effected on switching the current mode and fix some other small state management issues too in the same screen.The text was updated successfully, but these errors were encountered: