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_REPOSTS = 'repost';
|
||||
|
||||
let session;
|
||||
|
||||
type Props = {
|
||||
uploadCount: number,
|
||||
claimsByUri: { [string]: any },
|
||||
|
@ -27,7 +29,7 @@ type Props = {
|
|||
fetching: boolean,
|
||||
urls: Array<string>,
|
||||
urlTotal: number,
|
||||
history: { replace: (string) => void, push: (string) => void },
|
||||
history: { action: string, replace: (string) => void, push: (string) => void },
|
||||
page: number,
|
||||
pageSize: number,
|
||||
doFetchViewCount: (claimIdCsv: string) => void,
|
||||
|
@ -43,11 +45,16 @@ function FileListPublished(props: Props) {
|
|||
fetching,
|
||||
urls,
|
||||
urlTotal,
|
||||
history,
|
||||
page,
|
||||
pageSize,
|
||||
doFetchViewCount,
|
||||
} = props;
|
||||
|
||||
const { action: historyAction } = history;
|
||||
const refreshedPage = session === undefined;
|
||||
const navigated = historyAction === 'POP' && !refreshedPage;
|
||||
|
||||
const [filterBy, setFilterBy] = React.useState(FILTER_ALL);
|
||||
const params = {};
|
||||
|
||||
|
@ -56,16 +63,20 @@ function FileListPublished(props: Props) {
|
|||
|
||||
const paramsString = JSON.stringify(params);
|
||||
|
||||
React.useEffect(() => {
|
||||
session = Date.now();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
checkPendingPublishes();
|
||||
}, [checkPendingPublishes]);
|
||||
|
||||
useEffect(() => {
|
||||
if (paramsString && fetchClaimListMine) {
|
||||
if (paramsString && fetchClaimListMine && !navigated) {
|
||||
const params = JSON.parse(paramsString);
|
||||
fetchClaimListMine(params.page, params.page_size, true, filterBy.split(','));
|
||||
}
|
||||
}, [uploadCount, paramsString, filterBy, fetchClaimListMine]);
|
||||
}, [uploadCount, paramsString, filterBy, fetchClaimListMine, navigated]);
|
||||
|
||||
useFetchViewCount(!fetching, urls, claimsByUri, doFetchViewCount);
|
||||
|
||||
|
|
Loading…
Reference in a new issue