mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-24 22:03:21 +03:00
update subscriptiogn removal for feed screen components
This commit is contained in:
parent
7c5d9cb83b
commit
6e7f0f04cd
@ -49,12 +49,14 @@ const PostsContainer = ({
|
||||
feedSubfilterOptionsValue,
|
||||
isFeedScreen = false,
|
||||
}) => {
|
||||
const appState = useRef(AppState.currentState);
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const intl = useIntl();
|
||||
let _postFetchTimer = null;
|
||||
|
||||
const appState = useRef(AppState.currentState);
|
||||
const appStateSubRef = useRef(null);
|
||||
|
||||
const nsfw = useSelector((state) => state.application.nsfw);
|
||||
const initPosts = useSelector((state) => state.posts.initPosts);
|
||||
const isConnected = useSelector((state) => state.application.isConnected);
|
||||
@ -295,8 +297,9 @@ const PostsContainer = ({
|
||||
const isMountedRef = useIsMountedRef();
|
||||
|
||||
useEffect(() => {
|
||||
let appStateSub;
|
||||
if (isFeedScreen) {
|
||||
AppState.addEventListener('change', _handleAppStateChange);
|
||||
appStateSub = AppState.addEventListener('change', _handleAppStateChange);
|
||||
_setFeedPosts(initPosts || []);
|
||||
} else {
|
||||
_setFeedPosts([]);
|
||||
@ -306,8 +309,8 @@ const PostsContainer = ({
|
||||
if (_postFetchTimer) {
|
||||
clearTimeout(_postFetchTimer);
|
||||
}
|
||||
if (isFeedScreen) {
|
||||
AppState.removeEventListener('change', _handleAppStateChange);
|
||||
if (isFeedScreen && appStateSub) {
|
||||
appStateSub.remove();
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { AppState, NativeScrollEvent, NativeSyntheticEvent } from 'react-native';
|
||||
import { AppState, NativeEventSubscription, NativeScrollEvent, NativeSyntheticEvent } from 'react-native';
|
||||
import { debounce } from 'lodash';
|
||||
import PostsList from '../../postsList';
|
||||
import { fetchPromotedEntries, loadPosts } from '../services/tabbedPostsFetch';
|
||||
@ -63,6 +63,7 @@ const TabContent = ({
|
||||
//refs
|
||||
let postsListRef = useRef<PostsListRef>();
|
||||
const appState = useRef(AppState.currentState);
|
||||
const appStateSubRef = useRef<NativeEventSubscription|null>()
|
||||
const postsRef = useRef(posts);
|
||||
const sessionUserRef = useRef(sessionUser);
|
||||
|
||||
@ -73,7 +74,7 @@ const TabContent = ({
|
||||
//side effects
|
||||
useEffect(() => {
|
||||
if (isFeedScreen) {
|
||||
AppState.addEventListener('change', _handleAppStateChange);
|
||||
appStateSubRef.current = AppState.addEventListener('change', _handleAppStateChange);
|
||||
}
|
||||
|
||||
_initContent(true, feedUsername);
|
||||
@ -110,8 +111,8 @@ const TabContent = ({
|
||||
if (postFetchTimer) {
|
||||
clearTimeout(postFetchTimer);
|
||||
}
|
||||
if (isFeedScreen) {
|
||||
AppState.removeEventListener('change', _handleAppStateChange);
|
||||
if (isFeedScreen && appStateSubRef.current) {
|
||||
appStateSubRef.current.remove();
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user