Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions src/OfflineImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,13 @@ class OfflineImage extends React.Component {
}
};

// FIXME : Get rid of return true and improve render component logic
shouldComponentUpdate(nextProps, nextState) {
return true
// if (!nextState.path) return true
// return this.state.path !== nextState.path || this.props.opacity !== nextProps.opacity;
}

componentWillReceiveProps(nextProps) {
const nextSource = nextProps.source;
const reloadImage = nextProps.reloadImage;
componentDidMount(prevProps) {
const nextSource = prevProps.source;
const reloadImage = prevProps.reloadImage;

const source = this.props.source;
if (nextSource.uri !== source.uri){
const offlinePath = offlineImageStore.getImageOfflinePath(nextSource.uri);
const { source } = this.props;
if (prevProps.uri !== source.uri){
const offlinePath = offlineImageStore.getImageOfflinePath(source.uri);
this.setState({ path: offlinePath });
offlineImageStore.subscribe(source, this.handler, reloadImage);
}
Expand All @@ -61,7 +54,7 @@ class OfflineImage extends React.Component {
}
}

componentWillMount() {
componentDidMount() {
/**
* Always download and update image in offline store if 'reloadImage' === 'always', however
* Case 1: Show offline image if already exist
Expand Down