Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
[RN] Make react-native-img-cache optional at bundle time
Lyubo Marinov2818520c8f6e
diff --git a/react/features/base/participants/components/Avatar.native.js b/react/features/base/participants/components/Avatar.native.jsindex 68aeb2ead8..6b1ac6b758 100644--- a/react/features/base/participants/components/Avatar.native.js+++ b/react/features/base/participants/components/Avatar.native.js@@ -74,8 +74,9 @@ export default class Avatar extends Component {// uriconst prevURI = this.props && this.props.uri;const nextURI = nextProps && nextProps.uri;+ const assignState = !this.state;- if (prevURI !== nextURI || !this.state) {+ if (prevURI !== nextURI || assignState) {const nextState = {backgroundColor: this._getBackgroundColor(nextProps),@@ -92,10 +93,10 @@ export default class Avatar extends Component {source: _DEFAULT_SOURCE};- if (this.state) {- this.setState(nextState);- } else {+ if (assignState) {this.state = nextState;+ } else {+ this.setState(nextState);}// XXX @lyubomir: My logic for the character # bellow is as follows:@@ -113,22 +114,32 @@ export default class Avatar extends Component {// an image retrieval action.if (nextURI && !nextURI.startsWith('#')) {const nextSource = { uri: nextURI };+ const observer = () => {+ this._unmounted || this.setState((prevState, props) => {+ if (props.uri === nextURI+ && (!prevState.source+ || prevState.source.uri !== nextURI)) {+ return { source: nextSource };+ }++ return {};+ });+ };// Wait for the source/URI to load.- ImageCache.get().on(- nextSource,- /* observer */ () => {- this._unmounted || this.setState((prevState, props) => {- if (props.uri === nextURI- && (!prevState.source- || prevState.source.uri !== nextURI)) {- return { source: nextSource };- }-- return {};- });- },- /* immutable */ true);+ if (ImageCache) {+ ImageCache.get().on(+ nextSource,+ observer,+ /* immutable */ true);+ } else if (assignState) {+ this.state = {+ ...this.state,+ source: nextSource+ };+ } else {+ observer();+ }}}}diff --git a/react/features/mobile/image-cache/functions.js b/react/features/mobile/image-cache/functions.jsindex 5da9e1fdb3..6c8261966e 100644--- a/react/features/mobile/image-cache/functions.js+++ b/react/features/mobile/image-cache/functions.js@@ -27,5 +27,5 @@ function _onLoad() {* @returns {void}*/export function prefetch(source) {- ImageCache.get().on(source, /* observer */ _onLoad, /* immutable */ true);+ ImageCache && ImageCache.get().on(source, _onLoad, /* immutable */ true);}diff --git a/react/features/mobile/image-cache/middleware.js b/react/features/mobile/image-cache/middleware.jsindex 46cf35f42e..73c965856f 100644--- a/react/features/mobile/image-cache/middleware.js+++ b/react/features/mobile/image-cache/middleware.js@@ -39,7 +39,7 @@ MiddlewareRegistry.register(({ getState }) => next => action => {case APP_WILL_MOUNT:case CONFERENCE_FAILED:case CONFERENCE_LEFT:- ImageCache.get().clear();+ ImageCache && ImageCache.get().clear();break;case PARTICIPANT_ID_CHANGED:diff --git a/react/features/mobile/image-cache/react-native-img-cache.no.js b/react/features/mobile/image-cache/react-native-img-cache.no.jsnew file mode 100644index 0000000000..69a30afaee--- /dev/null+++ b/react/features/mobile/image-cache/react-native-img-cache.no.js@@ -0,0 +1,16 @@+// XXX The third-party react-native modules react-native-fetch-blob utilizes the+// same HTTP library as react-native i.e. okhttp. Unfortunately, that means that+// the versions of okhttp on which react-native and react-native-fetch-blob+// depend may have incompatible APIs. Such an incompatibility will be made+// apparent at compile time and the developer doing the compilation may choose+// to not compile react-native-fetch-blob's source code.++// XXX The choice between the use of react-native-img-cache could've been done+// at runtime based on whether NativeModules.RNFetchBlob is defined if only+// react-native-fetch-blob would've completely protected itself. At the time of+// this writing its source code appears to be attempting to protect itself from+// missing native binaries but that protection is incomplete and there's a+// TypeError.++import { Image } from 'react-native';+export { Image as CachedImage, undefined as ImageCache };