@spteck/react-controls-v2 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abstractions/IGraphProvider.d.ts +6 -0
- package/dist/abstractions/IGraphProvider.d.ts.map +1 -1
- package/dist/abstractions/providers/DefaultGraphClient.d.ts +1 -0
- package/dist/abstractions/providers/DefaultGraphClient.d.ts.map +1 -1
- package/dist/components/userCard/useUserProfile.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -2
- package/dist/index.mjs.map +1 -1
- package/dist/providers.js +1 -1
- package/dist/providers.js.map +1 -1
- package/dist/providers.mjs +24 -0
- package/dist/providers.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -25945,6 +25945,27 @@ const useUserProfile = (userId, providedContext) => {
|
|
|
25945
25945
|
return null;
|
|
25946
25946
|
}
|
|
25947
25947
|
}, [graphClient]);
|
|
25948
|
+
const getUserPhoto = useCallback(async (id) => {
|
|
25949
|
+
if (!graphClient) {
|
|
25950
|
+
console.warn("Graph client not available");
|
|
25951
|
+
return void 0;
|
|
25952
|
+
}
|
|
25953
|
+
try {
|
|
25954
|
+
const photoBlob = await graphClient.getBlob(`/users/${id}/photo/$value`);
|
|
25955
|
+
if (photoBlob) {
|
|
25956
|
+
return new Promise((resolve, reject) => {
|
|
25957
|
+
const reader = new FileReader();
|
|
25958
|
+
reader.onloadend = () => resolve(reader.result);
|
|
25959
|
+
reader.onerror = reject;
|
|
25960
|
+
reader.readAsDataURL(photoBlob);
|
|
25961
|
+
});
|
|
25962
|
+
}
|
|
25963
|
+
return void 0;
|
|
25964
|
+
} catch (error) {
|
|
25965
|
+
console.debug("No photo available for user:", id);
|
|
25966
|
+
return void 0;
|
|
25967
|
+
}
|
|
25968
|
+
}, [graphClient]);
|
|
25948
25969
|
const fetchUser = useCallback(async () => {
|
|
25949
25970
|
var _a3;
|
|
25950
25971
|
if (!userId) {
|
|
@@ -25962,6 +25983,7 @@ const useUserProfile = (userId, providedContext) => {
|
|
|
25962
25983
|
const fetchedUser = await getUserById(userId);
|
|
25963
25984
|
if (!fetchedUser) return;
|
|
25964
25985
|
let presence = { availability: "Offline", activity: "Offline" };
|
|
25986
|
+
let userPhoto;
|
|
25965
25987
|
try {
|
|
25966
25988
|
if (fetchedUser.id) {
|
|
25967
25989
|
const fetchedPresence = await getUserPresence(fetchedUser.id);
|
|
@@ -25988,7 +26010,18 @@ const useUserProfile = (userId, providedContext) => {
|
|
|
25988
26010
|
);
|
|
25989
26011
|
}
|
|
25990
26012
|
}
|
|
25991
|
-
|
|
26013
|
+
try {
|
|
26014
|
+
if (fetchedUser.id) {
|
|
26015
|
+
userPhoto = await getUserPhoto(fetchedUser.id);
|
|
26016
|
+
}
|
|
26017
|
+
} catch (error) {
|
|
26018
|
+
logError(
|
|
26019
|
+
"fetchUser: Error fetching user photo",
|
|
26020
|
+
error,
|
|
26021
|
+
ErrorType.Warning
|
|
26022
|
+
);
|
|
26023
|
+
}
|
|
26024
|
+
const userData = { ...fetchedUser, presence, userPhoto };
|
|
25992
26025
|
userCache.set(userId, {
|
|
25993
26026
|
data: userData,
|
|
25994
26027
|
timestamp: now,
|
|
@@ -26000,7 +26033,7 @@ const useUserProfile = (userId, providedContext) => {
|
|
|
26000
26033
|
} finally {
|
|
26001
26034
|
setLoading(false);
|
|
26002
26035
|
}
|
|
26003
|
-
}, [userId, getUserById, getUserPresence, logError]);
|
|
26036
|
+
}, [userId, getUserById, getUserPresence, getUserPhoto, logError]);
|
|
26004
26037
|
const checkUserPresence = useCallback(async () => {
|
|
26005
26038
|
var _a3;
|
|
26006
26039
|
if (!userId || !user) return;
|