fetchRemoteUserProfile method
Pulls the profile of a user from the server and merges it into the local store.
The profile syncs regardless of ActivityStoreConfig.syncEnabled. The outcome of the pull reaches ActivityStoreListener.registerOnUserProfileFetched.
Parameters
userID: The user.onComplete: Called with GemError.success when the pull started, or with GemError.notSupported when no session is set.
Returns
- The ProgressListener of the call, or null when it could not start.
Implementation
ProgressListener? fetchRemoteUserProfile(
String userID, {
void Function(GemError error)? onComplete,
}) {
final EventDrivenProgressListener progressListener =
EventDrivenProgressListener();
GemKitPlatform.instance.registerEventHandler(
progressListener.id,
progressListener,
);
progressListener.registerOnCompleteWithData((
int err,
String hint,
Map<dynamic, dynamic> json,
) {
GemKitPlatform.instance.unregisterEventHandler(progressListener.id);
onComplete?.call(GemErrorExtension.fromCode(err));
});
final OperationResult resultString = objectMethod(
pointerId,
'ActivityStore',
'fetchRemoteUserProfile',
args: <String, dynamic>{
'userID': userID,
'listener': progressListener.id,
},
);
final GemError errorCode = GemErrorExtension.fromCode(
resultString['result'],
);
if (errorCode != GemError.success) {
onComplete?.call(errorCode);
return null;
}
return progressListener;
}