Fix uploads page cleared/reloaded on each navigation
This commit is contained in:
parent
58167210ea
commit
1dccc1ac64
1 changed files with 14 additions and 3 deletions
|
@ -18,6 +18,8 @@ const FILTER_ALL = 'stream,repost';
|
||||||
const FILTER_UPLOADS = 'stream';
|
const FILTER_UPLOADS = 'stream';
|
||||||
const FILTER_REPOSTS = 'repost';
|
const FILTER_REPOSTS = 'repost';
|
||||||
|
|
||||||
|
let session;
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
uploadCount: number,
|
uploadCount: number,
|
||||||
claimsByUri: { [string]: any },
|
claimsByUri: { [string]: any },
|
||||||
|
@ -27,7 +29,7 @@ type Props = {
|
||||||
fetching: boolean,
|
fetching: boolean,
|
||||||
urls: Array<string>,
|
urls: Array<string>,
|
||||||
urlTotal: number,
|
urlTotal: number,
|
||||||
history: { replace: (string) => void, push: (string) => void },
|
history: { action: string, replace: (string) => void, push: (string) => void },
|
||||||
page: number,
|
page: number,
|
||||||
pageSize: number,
|
pageSize: number,
|
||||||
doFetchViewCount: (claimIdCsv: string) => void,
|
doFetchViewCount: (claimIdCsv: string) => void,
|
||||||
|
@ -43,11 +45,16 @@ function FileListPublished(props: Props) {
|
||||||
fetching,
|
fetching,
|
||||||
urls,
|
urls,
|
||||||
urlTotal,
|
urlTotal,
|
||||||
|
history,
|
||||||
page,
|
page,
|
||||||
pageSize,
|
pageSize,
|
||||||
doFetchViewCount,
|
doFetchViewCount,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
const { action: historyAction } = history;
|
||||||
|
const refreshedPage = session === undefined;
|
||||||
|
const navigated = historyAction === 'POP' && !refreshedPage;
|
||||||
|
|
||||||
const [filterBy, setFilterBy] = React.useState(FILTER_ALL);
|
const [filterBy, setFilterBy] = React.useState(FILTER_ALL);
|
||||||
const params = {};
|
const params = {};
|
||||||
|
|
||||||
|
@ -56,16 +63,20 @@ function FileListPublished(props: Props) {
|
||||||
|
|
||||||
const paramsString = JSON.stringify(params);
|
const paramsString = JSON.stringify(params);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
session = Date.now();
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
checkPendingPublishes();
|
checkPendingPublishes();
|
||||||
}, [checkPendingPublishes]);
|
}, [checkPendingPublishes]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (paramsString && fetchClaimListMine) {
|
if (paramsString && fetchClaimListMine && !navigated) {
|
||||||
const params = JSON.parse(paramsString);
|
const params = JSON.parse(paramsString);
|
||||||
fetchClaimListMine(params.page, params.page_size, true, filterBy.split(','));
|
fetchClaimListMine(params.page, params.page_size, true, filterBy.split(','));
|
||||||
}
|
}
|
||||||
}, [uploadCount, paramsString, filterBy, fetchClaimListMine]);
|
}, [uploadCount, paramsString, filterBy, fetchClaimListMine, navigated]);
|
||||||
|
|
||||||
useFetchViewCount(!fetching, urls, claimsByUri, doFetchViewCount);
|
useFetchViewCount(!fetching, urls, claimsByUri, doFetchViewCount);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue