Keep postlist scroll position on iOS and fix opengraph (#2369)

This commit is contained in:
Elias Nahum 2018-11-23 12:01:14 -03:00 committed by Sudheer
parent aa9fef955f
commit 24db914fd4
2 changed files with 15 additions and 1 deletions

View file

@ -30,6 +30,16 @@ function makeGetFirstLink() {
};
}
function getOpenGraphData(metadata, url) {
if (!metadata || !metadata.embeds) {
return null;
}
return metadata.embeds.find((embed) => {
return embed.type === 'opengraph' && embed.url === url ? embed.data : null;
});
}
function makeMapStateToProps() {
const getFirstLink = makeGetFirstLink();
@ -46,7 +56,7 @@ function makeMapStateToProps() {
...getDimensions(state),
googleDeveloperKey: config.GoogleDeveloperKey,
link,
openGraphData: getOpenGraphMetadataForUrl(state, link),
openGraphData: getOpenGraphMetadataForUrl(state, link) || getOpenGraphData(ownProps.metadata, link)?.data,
showLinkPreviews: previewsEnabled && config.EnableLinkPreviews === 'true',
theme: getTheme(state),
};

View file

@ -11,6 +11,9 @@ import PostListBase from './post_list_base';
const INITIAL_BATCH_TO_RENDER = 15;
const SCROLL_UP_MULTIPLIER = 3.5;
const SCROLL_POSITION_CONFIG = {
minIndexForVisible: 0,
};
export default class PostList extends PostListBase {
constructor(props) {
@ -115,6 +118,7 @@ export default class PostList extends PostListBase {
inverted={true}
keyExtractor={this.keyExtractor}
ListFooterComponent={this.props.renderFooter}
maintainVisibleContentPosition={SCROLL_POSITION_CONFIG}
maxToRenderPerBatch={INITIAL_BATCH_TO_RENDER + 1}
onContentSizeChange={this.handleContentSizeChange}
onLayout={this.handleLayout}