Skip to content

Commit

Permalink
fix: fixed profile picture fetch methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Sardar1208 committed Dec 21, 2023
1 parent a9f2e66 commit 972855c
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
BiometricStorageMacOSPlugin.register(with: registry.registrar(forPlugin: "BiometricStorageMacOSPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
Expand Down
53 changes: 52 additions & 1 deletion packages/at_contacts_flutter/lib/services/contact_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,11 @@ class ContactService {
key.metadata?.isBinary = true;
key.key = contactFields[2];
Uint8List? image;
var result = await atClientManager.atClient.get(key);

GetRequestOptions options = GetRequestOptions();
options.bypassCache = true;
var result =
await atClientManager.atClient.get(key, getRequestOptions: options);

if (result.value != null) {
try {
Expand All @@ -595,6 +599,53 @@ class ContactService {
return contactDetails;
}

getProfilePicture(String atsign) async {
var contactDetails = <String, dynamic>{};

var metadata = Metadata();
metadata.isPublic = true;
metadata.namespaceAware = false;
var key = AtKey();
key.sharedBy = atsign;
key.metadata = metadata;
// making isPublic true (as get method changes it to false)
key.metadata?.isBinary = true;
key.key = "image.wavi";

GetRequestOptions options = GetRequestOptions();
options.bypassCache = true;
var result =
await atClientManager.atClient.get(key, getRequestOptions: options);

if (result.value != null) {
try {
List<int> intList = result.value.cast<int>();
var image = Uint8List.fromList(intList);
contactDetails['image'] = image;
return contactDetails;
} catch (e) {
print('invalid iamge data: $e');
contactDetails['image'] = null;
return contactDetails;
}
}
}

fetchProfilePictureMetaData(String atsign) async {
var metadata = Metadata();
metadata.isPublic = true;
metadata.namespaceAware = false;
var key = AtKey();
key.sharedBy = atsign;
key.metadata = metadata;
// making isPublic true (as get method changes it to false)
key.metadata?.isBinary = true;
key.key = "image.wavi";

var result = await atClientManager.atClient.getMeta(key);
return result;
}

/// updates status of contacts for [baseContactList] and [baseBlockedList]
void updateState(STATE_UPDATE stateToUpdate, AtContact contact, bool state) {
int indexToUpdate;
Expand Down

0 comments on commit 972855c

Please sign in to comment.