Browse Source

fix(participants) do not preload gravatars if config is empty

Previously gravatars (external resources) were preloaded even if
disableThirdPartyRequests was set to true in the config, as the
config may be empty at the time of preloading.

Closes: #5670
Signed-off-by: Christoph Settgast <csett86@web.de>
j8
Christoph Settgast 3 years ago
parent
commit
1b200abaa7
1 changed files with 14 additions and 10 deletions
  1. 14
    10
      react/features/base/participants/middleware.js

+ 14
- 10
react/features/base/participants/middleware.js View File

407
     // to the new avatar and emit out change events if necessary.
407
     // to the new avatar and emit out change events if necessary.
408
     const result = next(action);
408
     const result = next(action);
409
 
409
 
410
-    const { disableThirdPartyRequests } = getState()['features/base/config'];
411
-
412
-    if (!disableThirdPartyRequests && (avatarURL || email || id || name)) {
413
-        const participantId = !id && local ? getLocalParticipant(getState()).id : id;
414
-        const updatedParticipant = getParticipantById(getState(), participantId);
415
-
416
-        getFirstLoadableAvatarUrl(updatedParticipant, store)
417
-            .then(url => {
418
-                dispatch(setLoadableAvatarUrl(participantId, url));
419
-            });
410
+    // Only run this if the config is populated, otherwise we preload external resources
411
+    // even if disableThirdPartyRequests is set to true in config
412
+    if (Object.keys(getState()['features/base/config']).length) {
413
+        const { disableThirdPartyRequests } = getState()['features/base/config'];
414
+
415
+        if (!disableThirdPartyRequests && (avatarURL || email || id || name)) {
416
+            const participantId = !id && local ? getLocalParticipant(getState()).id : id;
417
+            const updatedParticipant = getParticipantById(getState(), participantId);
418
+
419
+            getFirstLoadableAvatarUrl(updatedParticipant, store)
420
+                .then(url => {
421
+                    dispatch(setLoadableAvatarUrl(participantId, url));
422
+                });
423
+        }
420
     }
424
     }
421
 
425
 
422
     // Notify external listeners of potential avatarURL changes.
426
     // Notify external listeners of potential avatarURL changes.

Loading…
Cancel
Save