Commit 6467e1f0 authored by Juan Manuel Solaro's avatar Juan Manuel Solaro

(feat) scroll to index after remind from subscribed list

1 merge request!396[Sprint/PinkPanther] (feat) scroll to index after remind from subscribed list
......@@ -38,7 +38,7 @@ import CaptureTabs from './CaptureTabs';
// workaround for android copy/paste
import TextInput from '../common/components/TextInput';
@inject('user', 'capture')
@inject('user', 'capture', 'newsfeed')
@observer
export default class CapturePoster extends Component {
......@@ -353,6 +353,7 @@ export default class CapturePoster extends Component {
try {
const response = await this.props.capture.remind(params.entity.guid, post);
this.props.newsfeed.userJustReminded = params.activityIndex || false;
this.navToPrevious(response.entity, group);
} catch (err) {
logService.exception('[CapturePoster]', err);
......
......@@ -56,6 +56,14 @@ export default class FeedList extends Component {
this.listRef.scrollToOffset({animated, offset:0});
}
componentDidUpdate() {
if (this.props.newsfeed && this.props.newsfeed.userJustReminded) {
const itemIndex = this.props.newsfeed.userJustReminded;
this.props.newsfeed.userJustReminded = false;
this.props.newsfeed.scrollToIndex(itemIndex + 1); //+1 because of the just appended activity
}
}
/**
* Set list reference
*/
......@@ -213,6 +221,7 @@ export default class FeedList extends Component {
navigation={this.props.navigation}
autoHeight={false}
isLast={isLast}
activityIndex={row.index}
/>
</ErrorBoundary>
)
......
......@@ -115,6 +115,7 @@ export default class NewsfeedScreen extends Component {
feedStore={newsfeed.feedStore}
header={header}
navigation={this.props.navigation}
newsfeed={newsfeed}
/>
<CaptureFab navigation={this.props.navigation}/>
</View>
......
......@@ -22,6 +22,11 @@ class NewsfeedStore {
*/
listRef;
/**
* If the user reminded, contains remind height
*/
userJustReminded = false;
service = new NewsfeedService;
@observable filter = 'subscribed';
......@@ -53,6 +58,16 @@ class NewsfeedStore {
this.listRef.scrollToTop(false);
}
scrollToIndex(index, animated = true) {
if (this.filter !== 'subscribed') return;
this.listRef.listRef.scrollToIndex({
animated: animated,
index: index,
viewOffset: 0,
viewPosition: 0
});
}
/**
* Set FeedList reference
*/
......
......@@ -36,7 +36,7 @@ export default class Actions extends PureComponent {
<ThumbDownAction entity={entity} me={this.props.user.me}/>
{!isOwner && featuresService.has('crypto') && <WireAction owner={entity.ownerObj} navigation={this.props.navigation}/>}
<CommentsAction entity={entity} navigation={this.props.navigation}/>
<RemindAction entity={entity} navigation={this.props.navigation}/>
<RemindAction entity={entity} navigation={this.props.navigation} activityIndex={this.props.activityIndex}/>
{isOwner && featuresService.has('crypto') && <BoostAction entity={entity} navigation={this.props.navigation}/>}
</View> }
</View>
......
......@@ -257,6 +257,7 @@ export default class Activity extends Component {
return <Actions
entity={this.props.entity}
navigation={this.props.navigation}
activityIndex={this.props.activityIndex}
/>
}
}
......
......@@ -50,7 +50,7 @@ export default class RemindAction extends PureComponent {
*/
remind = () => {
const { state } = this.props.navigation
this.props.navigation.push('Capture', {isRemind: true, entity: this.props.entity, parentKey: state.key});
this.props.navigation.push('Capture', {isRemind: true, entity: this.props.entity, parentKey: state.key, activityIndex: this.props.activityIndex});
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment