renamed collectionLatestfile to collectionAndItsLatestFile
This commit is contained in:
parent
21297e6e73
commit
a4a3ad2e40
|
@ -9,7 +9,7 @@ function CollectionDropZone({
|
|||
closeModal,
|
||||
showModal,
|
||||
refetchData,
|
||||
collectionLatestFile,
|
||||
collectionAndItsLatestFile,
|
||||
setProgressView,
|
||||
progressBarProps
|
||||
|
||||
|
@ -21,7 +21,7 @@ function CollectionDropZone({
|
|||
progressBarProps.setPercentComplete(0);
|
||||
setProgressView(true);
|
||||
|
||||
await UploadService.uploadFiles(acceptedFiles, collectionLatestFile, token, progressBarProps);
|
||||
await UploadService.uploadFiles(acceptedFiles, collectionAndItsLatestFile, token, progressBarProps);
|
||||
refetchData();
|
||||
setProgressView(false);
|
||||
}
|
||||
|
|
|
@ -10,17 +10,16 @@ function CollectionSelector(props) {
|
|||
uploadModalView,
|
||||
closeUploadModal,
|
||||
showUploadModal,
|
||||
collectionLatestFile,
|
||||
collectionAndItsLatestFile,
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
|
||||
const CollectionIcons = collectionLatestFile?.map((item) => (
|
||||
const CollectionIcons = collectionAndItsLatestFile?.map((item) => (
|
||||
<CollectionDropZone key={item.collection.id}
|
||||
{...rest}
|
||||
closeModal={closeUploadModal}
|
||||
showModal={showUploadModal}
|
||||
collectionLatestFile={item}
|
||||
collectionAndItsLatestFile={item}
|
||||
>
|
||||
<Card>
|
||||
<PreviewCard data={item.file} updateUrl={() => { }} forcedEnable />
|
||||
|
|
|
@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|||
import { Button, Form, Modal } from 'react-bootstrap';
|
||||
import { createAlbum } from 'services/collectionService';
|
||||
import UploadService from 'services/uploadService';
|
||||
import { collectionLatestFile } from 'services/collectionService'
|
||||
import { CollectionAndItsLatestFile } from 'services/collectionService'
|
||||
import { getToken } from 'utils/common/key';
|
||||
|
||||
export default function CreateCollection(props) {
|
||||
|
@ -35,12 +35,12 @@ export default function CreateCollection(props) {
|
|||
|
||||
const collection = await createAlbum(albumName);
|
||||
|
||||
const collectionLatestFile: collectionLatestFile = { collection, file: null }
|
||||
const collectionAndItsLatestFile: CollectionAndItsLatestFile = { collection, file: null }
|
||||
|
||||
progressBarProps.setPercentComplete(0);
|
||||
setProgressView(true);
|
||||
|
||||
await UploadService.uploadFiles(acceptedFiles, collectionLatestFile, token, progressBarProps);
|
||||
await UploadService.uploadFiles(acceptedFiles, collectionAndItsLatestFile, token, progressBarProps);
|
||||
refetchData();
|
||||
setProgressView(false);
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ import Upload from './components/Upload';
|
|||
import {
|
||||
collection,
|
||||
syncCollections,
|
||||
collectionLatestFile,
|
||||
getCollectionLatestFile,
|
||||
CollectionAndItsLatestFile,
|
||||
getCollectionAndItsLatestFile,
|
||||
getFavItemIds,
|
||||
getLocalCollections,
|
||||
} from 'services/collectionService';
|
||||
import constants from 'utils/strings/constants';
|
||||
|
||||
const DATE_CONTAINER_HEIGHT = 30;
|
||||
const DATE_CONTAINER_HEIGHT = 45;
|
||||
const IMAGE_CONTAINER_HEIGHT = 200;
|
||||
const NO_OF_PAGES = 2;
|
||||
|
||||
|
@ -108,9 +108,10 @@ export default function Gallery(props) {
|
|||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [collections, setCollections] = useState<collection[]>([]);
|
||||
const [collectionLatestFile, setCollectionLatestFile] = useState<
|
||||
collectionLatestFile[]
|
||||
>([]);
|
||||
const [
|
||||
collectionAndItsLatestFile,
|
||||
setCollectionAndItsLatestFile,
|
||||
] = useState<CollectionAndItsLatestFile[]>([]);
|
||||
const [data, setData] = useState<file[]>();
|
||||
const [favItemIds, setFavItemIds] = useState<Set<number>>();
|
||||
const [open, setOpen] = useState(false);
|
||||
|
@ -132,8 +133,13 @@ export default function Gallery(props) {
|
|||
setLoading(true);
|
||||
const data = await localFiles();
|
||||
const collections = await getLocalCollections();
|
||||
const collectionAndItsLatestFile = await getCollectionAndItsLatestFile(
|
||||
collections,
|
||||
data
|
||||
);
|
||||
setData(data);
|
||||
setCollections(collections);
|
||||
setCollectionAndItsLatestFile(collectionAndItsLatestFile);
|
||||
setLoading(false);
|
||||
setProgress(80);
|
||||
await syncWithRemote();
|
||||
|
@ -148,7 +154,7 @@ export default function Gallery(props) {
|
|||
const encryptionKey = await getActualKey();
|
||||
const collections = await syncCollections(token, encryptionKey);
|
||||
const { data, isUpdated } = await syncData(token, collections);
|
||||
const collectionLatestFile = await getCollectionLatestFile(
|
||||
const collectionAndItsLatestFile = await getCollectionAndItsLatestFile(
|
||||
collections,
|
||||
data
|
||||
);
|
||||
|
@ -157,7 +163,7 @@ export default function Gallery(props) {
|
|||
if (isUpdated) {
|
||||
setData(data);
|
||||
}
|
||||
setCollectionLatestFile(collectionLatestFile);
|
||||
setCollectionAndItsLatestFile(collectionAndItsLatestFile);
|
||||
setFavItemIds(favItemIds);
|
||||
setSinceTime(new Date().getTime());
|
||||
props.setUploadButtonView(true);
|
||||
|
@ -340,7 +346,7 @@ export default function Gallery(props) {
|
|||
uploadModalView={props.uploadModalView}
|
||||
closeUploadModal={props.closeUploadModal}
|
||||
showUploadModal={props.showUploadModal}
|
||||
collectionLatestFile={collectionLatestFile}
|
||||
collectionAndItsLatestFile={collectionAndItsLatestFile}
|
||||
refetchData={syncWithRemote}
|
||||
/>
|
||||
{filteredData.length ? (
|
||||
|
|
|
@ -44,7 +44,7 @@ interface collectionAttributes {
|
|||
pathDecryptionNonce?: string;
|
||||
}
|
||||
|
||||
export interface collectionLatestFile {
|
||||
export interface CollectionAndItsLatestFile {
|
||||
collection: collection;
|
||||
file: file;
|
||||
}
|
||||
|
@ -157,10 +157,10 @@ export const syncCollections = async (token: string, key: string) => {
|
|||
return collections;
|
||||
};
|
||||
|
||||
export const getCollectionLatestFile = (
|
||||
export const getCollectionAndItsLatestFile = (
|
||||
collections: collection[],
|
||||
files: file[]
|
||||
): collectionLatestFile[] => {
|
||||
): CollectionAndItsLatestFile[] => {
|
||||
const latestFile = new Map<number, file>();
|
||||
const collectionMap = new Map<number, collection>();
|
||||
|
||||
|
@ -172,14 +172,14 @@ export const getCollectionLatestFile = (
|
|||
latestFile.set(file.collectionID, file);
|
||||
}
|
||||
});
|
||||
let allCollectionLatestFile: collectionLatestFile[] = [];
|
||||
let allCollectionAndItsLatestFile: CollectionAndItsLatestFile[] = [];
|
||||
for (const [collectionID, file] of latestFile) {
|
||||
allCollectionLatestFile.push({
|
||||
allCollectionAndItsLatestFile.push({
|
||||
collection: collectionMap.get(collectionID),
|
||||
file,
|
||||
});
|
||||
}
|
||||
return allCollectionLatestFile;
|
||||
return allCollectionAndItsLatestFile;
|
||||
};
|
||||
|
||||
export const getFavItemIds = async (files: file[]): Promise<Set<number>> => {
|
||||
|
|
|
@ -3,7 +3,7 @@ import HTTPService from './HTTPService';
|
|||
import * as Comlink from 'comlink';
|
||||
import EXIF from "exif-js";
|
||||
import { fileAttribute } from './fileService';
|
||||
import { collection, collectionLatestFile } from "./collectionService"
|
||||
import { collection, CollectionAndItsLatestFile } from "./collectionService"
|
||||
import { FILE_TYPE } from 'pages/gallery';
|
||||
const CryptoWorker: any =
|
||||
typeof window !== 'undefined' &&
|
||||
|
@ -80,7 +80,7 @@ class UploadService {
|
|||
private totalFilesCount: number
|
||||
private metadataMap: Map<string, Object>;
|
||||
|
||||
public async uploadFiles(recievedFiles: File[], collectionLatestFile: collectionLatestFile, token: string, progressBarProps) {
|
||||
public async uploadFiles(recievedFiles: File[], collectionAndItsLatestFile: CollectionAndItsLatestFile, token: string, progressBarProps) {
|
||||
try {
|
||||
const worker = await new CryptoWorker();
|
||||
this.stepsCompleted = 0;
|
||||
|
@ -107,7 +107,7 @@ class UploadService {
|
|||
while (actualFiles.length > 0) {
|
||||
var promises = [];
|
||||
for (var i = 0; i < 5 && actualFiles.length > 0; i++)
|
||||
promises.push(this.uploadHelper(progressBarProps, actualFiles.pop(), collectionLatestFile.collection, token));
|
||||
promises.push(this.uploadHelper(progressBarProps, actualFiles.pop(), collectionAndItsLatestFile.collection, token));
|
||||
uploadFilesWithoutMetaData.push(...await Promise.all(promises));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue