no need to fetch use info in init state of homepage and agreement dialog

This commit is contained in:
raf-dev1
2025-06-10 16:33:33 +03:00
parent fd192894cd
commit 0e31a3ea96

View File

@ -24,7 +24,7 @@ class _HomeWebPageState extends State<HomeWebPage> {
void initState() {
super.initState();
final homeBloc = BlocProvider.of<HomeBloc>(context);
homeBloc.add(const FetchUserInfo());
// homeBloc.add(const FetchUserInfo());
}
@override
@ -38,8 +38,10 @@ class _HomeWebPageState extends State<HomeWebPage> {
child: BlocConsumer<HomeBloc, HomeState>(
listener: (BuildContext context, state) {
if (state is HomeInitial) {
if (homeBloc.user!.hasAcceptedWebAgreement == false && !_dialogShown) {
_dialogShown = true; // Set the flag to true to indicate the dialog is showing.
if (homeBloc.user!.hasAcceptedWebAgreement == false &&
!_dialogShown) {
_dialogShown =
true; // Set the flag to true to indicate the dialog is showing.
Future.delayed(const Duration(seconds: 1), () {
showDialog(
context: context,
@ -54,7 +56,7 @@ class _HomeWebPageState extends State<HomeWebPage> {
_dialogShown = false;
if (v != null) {
homeBloc.add(ConfirmUserAgreementEvent());
homeBloc.add(const FetchUserInfo());
// homeBloc.add(const FetchUserInfo());
}
});
});
@ -98,7 +100,8 @@ class _HomeWebPageState extends State<HomeWebPage> {
width: size.width * 0.68,
child: GridView.builder(
itemCount: homeBloc.homeItems.length,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3, // Adjust as needed.
crossAxisSpacing: 20.0,
mainAxisSpacing: 20.0,
@ -110,7 +113,8 @@ class _HomeWebPageState extends State<HomeWebPage> {
active: homeBloc.homeItems[index].active!,
name: homeBloc.homeItems[index].title!,
img: homeBloc.homeItems[index].icon!,
onTap: () => homeBloc.homeItems[index].onPress(context),
onTap: () =>
homeBloc.homeItems[index].onPress(context),
);
},
),