Merge pull request #1784 from ecency/bugfix/unmounted

Fixed unmounted component issue
This commit is contained in:
Feruz M 2020-10-24 20:56:33 +03:00 committed by GitHub
commit fa889ad09b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 83 additions and 78 deletions

View File

@ -143,7 +143,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch
versionName "3.0.8"
versionName "3.0.9"
resValue "string", "build_config_package", "app.esteem.mobile.android"
multiDexEnabled true
// react-native-image-crop-picker

View File

@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.8</string>
<string>3.0.9</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2558</string>
<string>2559</string>
<key>LSRequiresIPhoneOS</key>
<true />
<key>NSAppTransportSecurity</key>

View File

@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.8</string>
<string>3.0.9</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2558</string>
<string>2559</string>
</dict>
</plist>

View File

@ -1100,7 +1100,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2558;
CURRENT_PROJECT_VERSION = 2559;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = 75B6RXTKGT;
HEADER_SEARCH_PATHS = (
@ -1176,7 +1176,7 @@
CODE_SIGN_ENTITLEMENTS = Ecency/Ecency.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2558;
CURRENT_PROJECT_VERSION = 2559;
DEAD_CODE_STRIPPING = NO;
DEVELOPMENT_TEAM = 75B6RXTKGT;
HEADER_SEARCH_PATHS = (

View File

@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.8</string>
<string>3.0.9</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>

View File

@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.8</string>
<string>3.0.9</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2558</string>
<string>2559</string>
</dict>
</plist>

View File

@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>3.0.8</string>
<string>3.0.9</string>
<key>CFBundleVersion</key>
<string>2558</string>
<string>2559</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>

View File

@ -1,6 +1,6 @@
{
"name": "ecency",
"version": "3.0.8",
"version": "3.0.9",
"displayName": "Ecency",
"private": true,
"rnpm": {

View File

@ -15,7 +15,7 @@ import PostsView from '../view/postsView';
import { setFeedPosts } from '../../../redux/actions/postsAction';
import { hidePostsThumbnails } from '../../../redux/actions/uiAction';
let _isLoadingPost = false;
import useIsMountedRef from '../../../customHooks/useIsMountedRef';
const PostsContainer = ({
changeForceLoadPostState,
@ -51,6 +51,7 @@ const PostsContainer = ({
filterOptionsValue && filterOptionsValue[selectedFilterIndex],
);
const elem = useRef(null);
const isMountedRef = useIsMountedRef();
useEffect(() => {
if (isConnected) {
@ -119,15 +120,16 @@ const PostsContainer = ({
),
);
if (isMountedRef.current) {
setPromotedPosts(_promotedPosts);
}
}
})
.catch(() => {});
};
const _loadPosts = (type) => {
if (
_isLoadingPost ||
isLoading ||
!isConnected ||
(!isLoggedIn && type === 'feed') ||
@ -136,12 +138,10 @@ const PostsContainer = ({
return;
}
setIsLoading(true);
_isLoadingPost = true;
if (!isConnected && (refreshing || isLoading)) {
setRefreshing(false);
setIsLoading(false);
_isLoadingPost = false;
return;
}
@ -182,6 +182,7 @@ const PostsContainer = ({
}
func(options, username, nsfw)
.then((result) => {
if (isMountedRef.current) {
if (result.length > 0) {
let _posts = result;
@ -215,12 +216,11 @@ const PostsContainer = ({
}
setRefreshing(false);
setIsLoading(false);
_isLoadingPost = false;
}
})
.catch(() => {
setRefreshing(false);
setIsLoading(false);
_isLoadingPost = false;
});
// track filter and tag views
if (isAnalytics) {

View File

@ -1,3 +1,12 @@
export default ['rpc.esteem.app', 'api.hive.blog', 'anyx.io', 'api.pharesim.me'];
export const VALUE = ['rpc.esteem.app', 'api.hive.blog', 'anyx.io', 'api.pharesim.me'];
export const SERVER_LIST = [
'https://rpc.ecency.com',
'https://anyx.io',
'https://api.hive.blog',
'https://hive-api.arcange.eu',
'https://api.deathwing.me',
'https://rpc.ausbit.dev',
];

View File

@ -0,0 +1,12 @@
import { useEffect, useRef } from 'react';
export default () => {
const isMountedRef = useRef(null);
useEffect(() => {
isMountedRef.current = true;
return () => {
isMountedRef.current = false;
};
});
return isMountedRef;
};

View File

@ -5,6 +5,7 @@ import { upload } from '../../config/imageApi';
import serverList from '../../config/serverListApi';
import { jsonStringify } from '../../utils/jsonUtils';
import bugsnag from '../../config/bugsnag';
import { SERVER_LIST } from '../../constants/options/api';
export const getCurrencyRate = (currency) =>
api
@ -372,19 +373,7 @@ export const uploadImage = (media, username, sign) => {
// });
// });
export const getNodes = () =>
serverList
.get()
.then(
(resp) =>
resp.data.hived || [
'https://rpc.ecency.com',
'https://api.hive.blog',
'https://anyx.io',
'https://rpc.esteem.app',
'https://api.openhive.network',
],
);
export const getNodes = () => serverList.get().then((resp) => resp.data.hived || SERVER_LIST);
export const getSCAccessToken = (code) =>
new Promise((resolve, reject) => {

View File

@ -25,18 +25,15 @@ import { getDsteemDateErrorMessage } from '../../utils/dsteemUtils';
// Constant
import AUTH_TYPE from '../../constants/authType';
import { SERVER_LIST } from '../../constants/options/api';
global.Buffer = global.Buffer || require('buffer').Buffer;
const DEFAULT_SERVER = [
'https://rpc.ecency.com',
'https://anyx.io',
'https://hive-api.arcange.eu',
'https://api.openhive.network',
'https://api.hive.blog',
];
const DEFAULT_SERVER = SERVER_LIST;
let client = new Client(DEFAULT_SERVER, {
timeout: 8000,
timeout: 3000,
failoverThreshold: 10,
consoleOnFailover: true,
rebrandedApi: true,
});
@ -50,7 +47,9 @@ export const checkClient = async () => {
});
client = new Client(selectedServer, {
timeout: 8000,
timeout: 3000,
failoverThreshold: 10,
consoleOnFailover: true,
rebrandedApi: true,
});
};

View File

@ -1,6 +1,7 @@
import axios from 'axios';
import { SERVER_LIST } from '../../constants/options/api';
const DEFAULT_SERVER = ['https://rpc.ecency.com', 'https://anyx.io', 'https://api.hive.blog'];
const DEFAULT_SERVER = SERVER_LIST;
const pickAServer = () => DEFAULT_SERVER.sort(() => 0.5 - Math.random())[0];

View File

@ -29,7 +29,7 @@ import {
} from '../constants/constants';
const initialState = {
api: 'rpc.esteem.app',
api: 'rpc.ecency.com',
currency: {
currency: 'usd',
currencyRate: 1,

View File

@ -49,6 +49,7 @@ import { encryptKey, decryptKey } from '../../../utils/crypto';
// Component
import SettingsScreen from '../screen/settingsScreen';
import { SERVER_LIST } from '../../../constants/options/api';
/*
* Props Name Description Value
@ -76,13 +77,7 @@ class SettingsContainer extends Component {
})
.catch(() =>
this.setState({
serverList: [
'https://rpc.ecency.com',
'https://api.hive.blog',
'https://anyx.io',
'https://rpc.esteem.app',
'https://api.openhive.network',
],
serverList: SERVER_LIST,
}),
);
}
@ -123,7 +118,7 @@ class SettingsContainer extends Component {
let isError = false;
let alertMessage;
const client = new Client(server, {
timeout: 8000,
timeout: 3000,
rebrandedApi: true,
});
dispatch(setApi(''));