Преглед на файлове

[RN] Prefetch remote avatar images 1/2

j8
Lyubo Marinov преди 8 години
родител
ревизия
97832e0eef

+ 5
- 0
react/features/base/participants/components/ParticipantView.native.js Целия файл

2
 import { connect } from 'react-redux';
2
 import { connect } from 'react-redux';
3
 
3
 
4
 import { JitsiParticipantConnectionStatus } from '../../lib-jitsi-meet';
4
 import { JitsiParticipantConnectionStatus } from '../../lib-jitsi-meet';
5
+import { prefetch } from '../../../mobile/image-cache';
5
 import {
6
 import {
6
     MEDIA_TYPE,
7
     MEDIA_TYPE,
7
     shouldRenderVideoTrack,
8
     shouldRenderVideoTrack,
209
         // runtime which means that, if their old and new avatar URLs fail to
210
         // runtime which means that, if their old and new avatar URLs fail to
210
         // download, Avatar will change their automatically-generated colors.
211
         // download, Avatar will change their automatically-generated colors.
211
         avatar || participant.local || (avatar = `#${participant.id}`);
212
         avatar || participant.local || (avatar = `#${participant.id}`);
213
+
214
+        // ParticipantView knows before Avatar that an avatar URL will be used
215
+        // so it's advisable to prefetch here.
216
+        avatar && prefetch({ uri: avatar });
212
     }
217
     }
213
 
218
 
214
     return {
219
     return {

+ 31
- 0
react/features/mobile/image-cache/functions.js Целия файл

1
+import { ImageCache } from 'react-native-img-cache';
2
+
3
+/**
4
+ * Notifies about the successful download of an <tt>Image</tt> source. The name
5
+ * is inspired by <tt>Image</tt>. The downloaded <tt>Image</tt> source is not
6
+ * available because (1) I do not know how to get it from {@link ImageCache} and
7
+ * (2) we do not need it bellow. The function was explicitly introduced to cut
8
+ * down on unnecessary <tt>ImageCache</tt> <tt>observer</tt> instances.
9
+ *
10
+ * @private
11
+ * @returns {void}
12
+ */
13
+function _onLoad() {
14
+    // ImageCache requires an observer; otherwise, we do not need it because we
15
+    // merely want to initiate the download and do not care what happens with it
16
+    // afterwards.
17
+}
18
+
19
+/**
20
+ * Initiates the retrieval of a specific <tt>Image</tt> source (if it has not
21
+ * been initiated already). Due to limitations of {@link ImageCache}, the source
22
+ * may have at most one <tt>uri</tt>. The name is inspired by <tt>Image</tt>.
23
+ *
24
+ * @param {Object} source - The <tt>Image</tt> source with preferably exactly
25
+ * one <tt>uri</tt>.
26
+ * @public
27
+ * @returns {void}
28
+ */
29
+export function prefetch(source) {
30
+    ImageCache.get().on(source, /* observer */ _onLoad, /* immutable */ true);
31
+}

+ 2
- 0
react/features/mobile/image-cache/index.js Целия файл

1
+export * from './functions';
2
+
1
 import './middleware';
3
 import './middleware';

Loading…
Отказ
Запис