Back

Realtime Problem

  • 0
  • Flutter
  • Realtime
Joshima
21 Jun, 2023, 16:57

the page on which it is working perfectly fine - ```class UserprofileView extends ConsumerWidget { final UserModel userModel; const UserprofileView({super.key, required this.userModel});

@override Widget build(BuildContext context, WidgetRef ref) { final currentUser = ref.watch(currentUserDetailsProvider).value;

TypeScript
UserModel copyOfUser = userModel;

return currentUser == null
    ? const Loader()
    : SafeArea(
      child: Scaffold(
        body: ref.watch(getLatestUserProfileDataProvider).when(
              data: (data) {
                if (data.events.contains(
                  'databases.*.collections.${AppConstants.APPWRITE_USERS_COLLECIION}.documents.${copyOfUser.uid}.update',
                )) {
                  copyOfUser = UserModel.fromMap(data.payload);
                }
                return UserProfile(user: copyOfUser);
              },
              error: (error, st) => ErrorText(
                error: error.toString(),
              ),
              loading: () {
                return UserProfile(user: copyOfUser);
              },
            ),
      ),
    );```
TL;DR
The user is experiencing an issue where the text fields in their edit profile page are not taking the values of the user's name and bio. They have shared code from their `onPressed` function and are looking for help in identifying the mistake. They are asked to add prints in `getLatestUserprofileData()` and `EditProfileView`, as well as to trigger an update after navigating to `EditProfileView`. The user has mentioned that nothing happens when they tap "edit profile" and that the page where it is not working is the edit profile page. There is a discussion about using the same provider and API function on both
Drake
21 Jun, 2023, 17:18

Are you using the same realtime instance between the two?

Joshima
21 Jun, 2023, 17:40

I tried changing it but that ain’t working either

Drake
21 Jun, 2023, 17:42

what are the logs? what's going on?

Please share how _realtime is initialized. Please also share details of currentUserDetailsProvider

Joshima
21 Jun, 2023, 17:52

currentUserDetailsProvider api function - @override Future<model.Document> getUserData(String uid) { return _db.getDocument( databaseId: AppConstants.APPWRITE_DATABASE_ID, collectionId: AppConstants.APPWRITE_USERS_COLLECIION, documentId: uid, ); } (for currentUser)

Joshima
21 Jun, 2023, 17:52

_realtime - class UserAPI implements IUserAPI { final Databases _db; final Realtime _realtime; UserAPI({ required Databases db, required Realtime realtime, }) : _db = db, _realtime = realtime;

Joshima
21 Jun, 2023, 17:53

api provider - final userAPIProvider = Provider((ref) { return UserAPI( db: ref.watch(apppwriteDatabaseProvider), realtime : ref.watch(apppwriteRealtimeForProfileProvider), ); });

Joshima
21 Jun, 2023, 17:53
TypeScript
  final client = ref.watch(appwriteClientProvider);
  return Realtime(client);
});```
Joshima
21 Jun, 2023, 17:53

appwriteclientProvider is where i am setting client endpoint and all

Drake
21 Jun, 2023, 18:09

btw, you can enable syntax highlighting if you add dart after the first 3 backticks

Drake
21 Jun, 2023, 18:10

and what's the code for getLatestUserProfileDataProvider?

Joshima
21 Jun, 2023, 19:01

Here

Joshima
21 Jun, 2023, 19:01

Provider and api function

Drake
21 Jun, 2023, 19:37

so you're using the same getLatestUserProfileDataProvider on both pages?

Drake
21 Jun, 2023, 19:38

@Joshima and what do the client logs say?

Drake
21 Jun, 2023, 19:40

and what is going on when you're saying "the page on which it is not working"

Joshima
22 Jun, 2023, 14:17

yes i am using same provider (i tried changing instance and also the provider accordingly but still not working)

Joshima
22 Jun, 2023, 14:17

the page on which it is working is my profile page and the page on which it is not working is my edit profile page

Joshima
22 Jun, 2023, 14:18

literally nothing when i tap "edit profile" not even subscription: null

Drake
22 Jun, 2023, 16:43

can you add some prints to check what's being executed?

  1. in getLatestUserprofileData()
  2. in EditProfileView

also...after you're on EditProfileView, you're making an update to trigger the event, right?

Joshima
22 Jun, 2023, 21:27

i tried printing data.payload and i am getting it in debug console correctly but i think where could the mistake

Joshima
22 Jun, 2023, 21:28

there are two textfields in editProfile , one for name and other for Bio

Joshima
22 Jun, 2023, 21:28

and i am doing something like this dart IconButton( splashColor: Color(0xffAAE148), highlightColor: Colors.transparent, onPressed: () { ref .read(userProfileControllerProvider.notifier) .updateUserProfile( userModel: widget.user.copyWith( bio: bioController.text, name: nameController.text), context: context, profileFile: profileFile, ); },

Joshima
22 Jun, 2023, 21:30

so that whatever the user fills will be seen on editprofile page but textfields are taking values of controller not the (user.name) , (user.bio) maybe this is the problem :_

Drake
22 Jun, 2023, 21:32

Maybe yes...

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more