Merge pull request #2027 from ecency/nt/notification-scroll

Nt/notification scroll
This commit is contained in:
Feruz M 2021-08-06 22:13:37 +03:00 committed by GitHub
commit 53c4ff2354
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 10 deletions

View File

@ -123,13 +123,21 @@ class NotificationView extends PureComponent {
},
];
notifications.forEach((item) => {
const listIndex = this._getTimeListIndex(item.timestamp);
notificationArray[listIndex].data.push(item);
let sectionIndex = -1;
return notifications.map((item) => {
const timeIndex = this._getTimeListIndex(item.timestamp);
if(timeIndex !== sectionIndex && timeIndex > sectionIndex){
if(sectionIndex === -1){
item.firstSection = true;
}
item.sectionTitle = notificationArray[timeIndex].title;
sectionIndex = timeIndex;
}
return item;
});
return notificationArray.filter((item) => item.data.length > 0).map((item, index)=>{item.index = index; return item});
};
// return notificationArray.filter((item) => item.data.length > 0).map((item, index)=>{item.index = index; return item});
};
_getTimeListIndex = (timestamp) => {
if (isToday(timestamp)) {
@ -165,10 +173,13 @@ class NotificationView extends PureComponent {
_renderItem = ({ item }) => (
<>
{item.sectionTitle && <ContainerHeader hasSeperator={!item.firstSection} isBoldTitle title={item.sectionTitle}/>}
<NotificationLine
notification={item}
handleOnPressNotification={this.props.navigateToNotificationRoute}
/>
</>
)
@ -194,14 +205,13 @@ class NotificationView extends PureComponent {
<ThemeContainer>
{({ isDarkTheme }) =>
_notifications && _notifications.length > 0 ? (
<SectionList
sections={_notifications}
<FlatList
data={_notifications}
keyExtractor={(item, index) => `${item.id}-${index}`}
onEndReached={() => getActivities(selectedFilter, true)}
ListFooterComponent={this._renderFooterLoading}
ListEmptyComponent={<ListPlaceHolder />}
contentContainerStyle={styles.listContentContainer}
stickySectionHeadersEnabled={false}
refreshControl={
<RefreshControl
refreshing={isNotificationRefreshing}
@ -213,7 +223,6 @@ class NotificationView extends PureComponent {
/>
}
renderItem={this._renderItem}
renderSectionHeader={this._renderSectionHeader}
/>
) : (
<Text style={globalStyles.hintText}>

View File

@ -51,7 +51,7 @@ class NotificationContainer extends Component {
isRefreshing: !loadMore,
isLoading: true,
});
getNotifications({ filter: type, since: since })
getNotifications({ filter: type, since: since, limit: 20 })
.then((res) => {
console.log(res);
const lastId = res.length > 0 ? [...res].pop().id : null;