Merge branch 'move-files' into disable-shared-collection-ops

This commit is contained in:
abhinav-grd 2021-09-22 12:34:12 +05:30
commit c98d4792be
3 changed files with 22 additions and 14 deletions

View file

@ -7,13 +7,17 @@ export default function MoveIcon(props) {
height={props.height}
viewBox={props.viewBox}
width={props.width}>
<path d="M13.025 1l-2.847 2.828 6.176 6.176h-16.354v3.992h16.354l-6.176 6.176 2.847 2.828 10.975-11z" />
<path
d="M13.025 1l-2.847 2.828 6.176 6.176h-16.354v3.992h16.354l-6.176 6.176 2.847 2.828 10.975-11z"
strokeWidth="2"
stroke="black"
/>
</svg>
);
}
MoveIcon.defaultProps = {
height: 20,
width: 20,
height: 24,
width: 24,
viewBox: '0 0 24 24',
};

View file

@ -15,6 +15,8 @@ import { SetCollectionNamerAttributes } from './CollectionNamer';
import CollectionOptions from './CollectionOptions';
import OptionIcon, { OptionIconWrapper } from './OptionIcon';
export const ALL_SECTION = 0;
interface CollectionProps {
collections: Collection[];
selected?: number;
@ -100,9 +102,9 @@ export default function Collections(props: CollectionProps) {
collectionRef.current.scrollLeft = 0;
}, [collections]);
const clickHandler = (collection?: Collection) => () => {
setSelectedCollectionID(collection?.id);
setActiveCollection(collection?.id);
const clickHandler = (collectionID?: number) => () => {
setSelectedCollectionID(collectionID);
setActiveCollection(collectionID ?? ALL_SECTION);
};
const user: User = getData(LS_KEYS.USER);
@ -119,7 +121,7 @@ export default function Collections(props: CollectionProps) {
setDialogMessage: props.setDialogMessage,
startLoadingBar: props.startLoadingBar,
showCollectionShareModal: setCollectionShareModalView.bind(null, true),
redirectToAll: setActiveCollection.bind(null, 0),
redirectToAll: setActiveCollection.bind(null, ALL_SECTION),
});
const scrollCollection = (direction: SCROLL_DIRECTION) => () => {
@ -171,7 +173,9 @@ export default function Collections(props: CollectionProps) {
/>
)}
<Wrapper ref={collectionRef} onScroll={updateScrollObj}>
<Chip active={!selected} onClick={clickHandler()}>
<Chip
active={!selected}
onClick={clickHandler(ALL_SECTION)}>
All
<div
style={{
@ -188,7 +192,7 @@ export default function Collections(props: CollectionProps) {
overlay={renderTooltip(item.id)}>
<Chip
active={selected === item.id}
onClick={clickHandler(item)}>
onClick={clickHandler(item.id)}>
{item.name}
{item.type !== CollectionType.favorites &&
item.owner.id === user?.id ? (

View file

@ -384,18 +384,18 @@ export const addToCollection = async (
}
};
export const moveToCollection = async (
oldCollectionID: number,
newCollection: Collection,
fromCollectionID: number,
toCollection: Collection,
files: File[]
) => {
try {
const token = getToken();
const fileKeysEncryptedWithNewCollection =
await encryptWithNewCollectionKey(newCollection, files);
await encryptWithNewCollectionKey(toCollection, files);
const requestBody: MoveToCollectionRequest = {
fromCollectionID: oldCollectionID,
toCollectionID: newCollection.id,
fromCollectionID: fromCollectionID,
toCollectionID: toCollection.id,
files: fileKeysEncryptedWithNewCollection,
};
await HTTPService.post(