Rank 3: Container
sure
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 3: Container
sure
Rank 3: Container
Hello I have attached below all my code related to userProfiel realtime update, I have tried for several hours on my own and still cant find a solution. Please help
final appwriteRealtimeProvider = Provider((ref) {
final client = ref.watch(appwriteClientProvider);
return Realtime(client);
});
// -------------------
Stream getLatestProfileData();
final userApiProvider = Provider((ref) {
final db = ref.watch(appwriteDatabaseProvider);
final realTime = ref.watch(appwriteRealtimeProvider);
return UserApi(db: db, realtime: realTime);
});
// --------------------
final getLatestUserProfileDataProvider = StreamProvider((ref) {
final userApi = ref.watch(userApiProvider);
return userApi.getLatestProfileData();
});
// ------------------------
import '../controller/user_profile_controller.dart';
import '../widget/user_profile.dart';
class UserProfileView extends ConsumerWidget {
static route(UserModel userModel) => MaterialPageRoute(
builder: (context) => UserProfileView(userModel: userModel),
);
const UserProfileView({super.key, required this.userModel});
final UserModel userModel;
@override
Widget build(BuildContext context, WidgetRef ref) {
UserModel copyOfUser = userModel;
return Scaffold(
body: ref.watch(getLatestUserProfileDataProvider).when(
data: (data) {
if (data.events.contains(
'databases.*.collections.${AppwriteConstants.usersCollection}.documents.${userModel.uid}.update')) {
copyOfUser = UserModel.fromMap(data.payload);
return UserProfile(userModel: copyOfUser);
}
return UserProfile(userModel: copyOfUser);
},
error: (error, stackTrace) => ErrorText(error: error.toString()),
loading: () {
return UserProfile(userModel: copyOfUser);
// return Loader();
},
),
);
}
}
Admin
Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting
Admin
Also...what exactly is wrong? What do you expect is happening vs the actual behavior?
Rank 3: Container
When I update my profile and and profile picture I expect it to reflect on the ui, it only happends when i restartt my app
Admin
Where are you calling subscribe?
Rank 3: Container
Aahhh!!! I am not sure where to do that
Rank 3: Container
😬
Rank 3: Container
I will aditionally add my link to repo,
https://github.com/nuaiman/flutter_appwrite_twitter_clone
Admin
Ref.when() is probably not the right approach, unless you change up the ref.
As mentioned in the docs, you have to subscribe and then listen to the stream: https://appwrite.io/docs/realtime
Rank 3: Container
Ohhhh
Rank 3: Container
I still dont understand, what to write
Admin
Look at how the subscription is created and used
Rank 3: Container
Okay, i will have a look at it and report back
Rank 3: Container
@Steven hello
Rank 3: Container
I am stuck in a situation
Rank 3: Container
I dont know what to write for a particular realTime
Rank 3: Container
let me exlain
Rank 3: Container
``
Rank 3: Container
Rank 3: Container
'databases.${AppwriteConstants.databaseId}.collections.${AppwriteConstants.chatsCollection}.documents.'
Rank 3: Container
I want to only get realtime document where the conversationId is matching with me
Rank 3: Container
@Binyamin
Admin
please don't randomly tag people as it can be disruptive
Admin
you'll have to filter this client side.
You might want to 👍🏼 this issue: https://github.com/appwrite/appwrite/issues/2490