-
Notifications
You must be signed in to change notification settings - Fork 58
fix: Removed network call to backend server when transitioning from "Member Profile" to "Send Request" screen. #138
base: develop
Are you sure you want to change the base?
Conversation
Removed network call to backend server when transitioning from "Member Profile" to "Send Request" screen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yashhalgaonkar can you please fill those Description & HOW THIS HAS BEEN Tested sections and also, do check the part of code/quality assurance section as well.
@robotjellyzone I have filled the Description and Test section. |
@yashhalgaonkar Just went through the PR, so basically instead of making the user network call when we click on the send request button like we did earlier, you are making the request when the page loads right? |
@techno-disaster Yeah. I have made network call inside the members_page_bloc.dart whenever an instance of MembersPageSuccess is created. |
The objective was reducing the extra api call, also the way you have implemented this the currentUser is fetched every time a new page is loaded in pagination, this would affect the UX, can you try and have some workaround this? |
No. Network calls are not made every time a new page is loaded during pagination. I checked it. |
await userRepository.getVerifiedUsers((currentState.users.length ~/ 10) + 1); | ||
final users = await userRepository | ||
.getVerifiedUsers((currentState.users.length ~/ 10) + 1); | ||
final User currentUser = await userRepository.getCurrentUser(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yashhalgaonkar I'm talking about this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the event added when the user scrolls to the end of the page to load more users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I am looking into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I use sqflite to store the current user info in local storage? This will make it easy to get current user info in all other parts of app as well, solving the problem once and for all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, give it a try
Removed the redundant network calls being made to fetch user when the refreshed and when scrolled to the end of the list.
yield MembersPageSuccess(users: users, hasReachedMax: false); | ||
final List<User> users = | ||
await userRepository.getVerifiedUsers(pageNumber); | ||
final User currentUser = await userRepository.getCurrentUser(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This network call will be made when the state is MembersPageInitial. This is a necessary call.
yield users.isEmpty | ||
? currentState.copyWith(hasReachedMax: true) | ||
: MembersPageSuccess( | ||
users: currentState.users + users, | ||
hasReachedMax: false, | ||
currentUser: currentState.currentUser, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here while initializing MembersPageSuccess, we need not make the network call again. So removed it.
Removed the redundant network calls being made to fetch user when the refreshed and when scrolled to the end of the list.
Now the network call for fetching the currentUser is made only once when state changes from MembersPageInitial state to MembersPageSuccess state, as it should be. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@anitab-org/qa-team can someone give this a test? you can find the apk in the github actions artifacts |
@techno-disaster the PR needs 1 more code review approval before the QA team can test. |
@anitab-org/coding-team can someone give this a quick review? |
Removed network call to backend server when transitioning from "Member Profile" to "Send Request" screen.
Description
There was a redundant network call being made while transitioning from Member Profile Page to Send Request Page to get the current user details. The motivation was to remove that call to save device resources and provide a more seamless service to the user.
I changed the members_page_state.dart to include currentUser of type User in MembersPageSuccess state. This will have all the details of the current user.
I changed members_page_bloc.dart to make all the network calls to get current user details and pass that to MembersPageSuccess object instance whenever it is created.
I changed members_page.dart to pass an instance of MembersPageBloc to MemberProfileScreen.
I changed the member_profile.dart to accept the instance of MemberPageBloc passed to it and use to to get current user details.
Fixes #121
Flutter Channel:
Type of Change:
Delete irrelevant options.
Code/Quality Assurance Only
How Has This Been Tested?
I have tested the code manually on my emulator and device. To reproduce, just go from Member Profile to Send Requesnt Page.
Checklist:
Delete irrelevant options.
Code/Quality Assurance Only