|
@@ -129,20 +129,20 @@ export default function Gallery(props) {
|
|
setCollections(collections);
|
|
setCollections(collections);
|
|
setLoading(false);
|
|
setLoading(false);
|
|
setProgress(80);
|
|
setProgress(80);
|
|
- await loadData();
|
|
|
|
|
|
+ await syncWithRemote();
|
|
setProgress(100);
|
|
setProgress(100);
|
|
};
|
|
};
|
|
main();
|
|
main();
|
|
props.setUploadButtonView(true);
|
|
props.setUploadButtonView(true);
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
- const loadData = async () => {
|
|
|
|
|
|
+ const syncWithRemote = async () => {
|
|
const token = getToken();
|
|
const token = getToken();
|
|
const encryptionKey = await getActualKey();
|
|
const encryptionKey = await getActualKey();
|
|
const updatedCollections = await fetchUpdatedCollections(token, encryptionKey);
|
|
const updatedCollections = await fetchUpdatedCollections(token, encryptionKey);
|
|
const data = await fetchData(token, updatedCollections);
|
|
const data = await fetchData(token, updatedCollections);
|
|
const collections = await getLocalCollections();
|
|
const collections = await getLocalCollections();
|
|
- const collectionLatestFile = await getCollectionLatestFile(collections, token);
|
|
|
|
|
|
+ const collectionLatestFile = await getCollectionLatestFile(collections, data);
|
|
const favItemIds = await getFavItemIds(data);
|
|
const favItemIds = await getFavItemIds(data);
|
|
if (updatedCollections.length > 0) {
|
|
if (updatedCollections.length > 0) {
|
|
setCollections(collections);
|
|
setCollections(collections);
|
|
@@ -150,7 +150,7 @@ export default function Gallery(props) {
|
|
}
|
|
}
|
|
setCollectionLatestFile(collectionLatestFile);
|
|
setCollectionLatestFile(collectionLatestFile);
|
|
setFavItemIds(favItemIds);
|
|
setFavItemIds(favItemIds);
|
|
-
|
|
|
|
|
|
+
|
|
props.setUploadButtonView(true);
|
|
props.setUploadButtonView(true);
|
|
}
|
|
}
|
|
if (!data || loading) {
|
|
if (!data || loading) {
|
|
@@ -206,7 +206,7 @@ export default function Gallery(props) {
|
|
|
|
|
|
const handleClose = () => {
|
|
const handleClose = () => {
|
|
setOpen(false);
|
|
setOpen(false);
|
|
- // setReload(Math.random());
|
|
|
|
|
|
+ // syncWithRemote();
|
|
};
|
|
};
|
|
|
|
|
|
const onThumbnailClick = (index: number) => () => {
|
|
const onThumbnailClick = (index: number) => () => {
|
|
@@ -322,7 +322,7 @@ export default function Gallery(props) {
|
|
closeUploadModal={props.closeUploadModal}
|
|
closeUploadModal={props.closeUploadModal}
|
|
showUploadModal={props.showUploadModal}
|
|
showUploadModal={props.showUploadModal}
|
|
collectionLatestFile={collectionLatestFile}
|
|
collectionLatestFile={collectionLatestFile}
|
|
- refetchData={loadData}
|
|
|
|
|
|
+ refetchData={syncWithRemote}
|
|
|
|
|
|
/>
|
|
/>
|
|
{filteredData.length ? (
|
|
{filteredData.length ? (
|