continued dep injectiong

This commit is contained in:
subnub
2024-07-02 15:10:03 -04:00
parent 09cb81f96d
commit 7bd81a9aa5
16 changed files with 413 additions and 336 deletions
+5 -1
View File
@@ -21,7 +21,7 @@ import {
} from "../../api/foldersAPI";
import { useClickOutOfBounds, useUtils } from "../../hooks/utils";
import { useAppDispatch } from "../../hooks/store";
import { setMultiSelectMode } from "../../reducers/selected";
import { resetSelected, setMultiSelectMode } from "../../reducers/selected";
import TrashIcon from "../../icons/TrashIcon";
import MultiSelectIcon from "../../icons/MultiSelectIcon";
import RenameIcon from "../../icons/RenameIcon";
@@ -98,6 +98,7 @@ const ContextMenu = (props) => {
await trashFileAPI(props.file._id);
invalidateFilesCache();
invalidateQuickFilesCache();
dispatch(resetSelected());
}
} else {
const result = await Swal.fire({
@@ -112,6 +113,7 @@ const ContextMenu = (props) => {
if (result.value) {
await trashFolderAPI(props.folder._id);
invalidateFoldersCache();
dispatch(resetSelected());
}
}
};
@@ -133,6 +135,7 @@ const ContextMenu = (props) => {
await deleteFileAPI(props.file._id);
invalidateFilesCache();
invalidateQuickFilesCache();
dispatch(resetSelected());
}
} else {
const result = await Swal.fire({
@@ -147,6 +150,7 @@ const ContextMenu = (props) => {
if (result.value) {
await deleteFolder(props.folder._id);
invalidateFoldersCache();
dispatch(resetSelected());
}
}
};
+6 -3
View File
@@ -6,8 +6,11 @@ import UploadOverlay from "../UploadOverlay";
import HomepageSpinner from "../HomepageSpinner";
import MobileContextMenuContainer from "../MobileContextMenu";
import ShareModelWrapper from "../ShareModelWrapper";
import PhotoViewer from "../PhotoViewer";
import { useAppSelector } from "../../hooks/store";
const Homepage2 = () => {
const Homepage = () => {
const photoID = useAppSelector((state) => state.photoViewer.id);
return (
<div>
<HomepageSpinner />
@@ -17,7 +20,7 @@ const Homepage2 = () => {
<div className="flex space-between">
<MainSection />
<Uploader />
{/* {photoID.length === 0 ? undefined : <PhotoViewer />} */}
{photoID.length === 0 ? undefined : <PhotoViewer />}
</div>
</div>
@@ -27,4 +30,4 @@ const Homepage2 = () => {
);
};
export default Homepage2;
export default Homepage;
+15 -14
View File
@@ -2,20 +2,21 @@ import React from "react";
import Spinner from "../Spinner";
const PhotoViewer = (props) => (
<div className="photoviewer">
<div className="photoviewer z-50">
<img
className="photoviewer__close-button"
onClick={props.closePhotoViewer}
src="/images/close-white-png.png"
/>
<img className="photoviewer__close-button" onClick={props.closePhotoViewer} src="/images/close-white-png.png"/>
{props.state.image === "" ?
<div className="photoviewer__loader">
{props.state.image === "" ? (
<div className="photoviewer__loader">
<Spinner />
</div>
:
<img className="photoviewer__image" src={props.state.image}/>
}
</div>
) : (
<img className="photoviewer__image" src={props.state.image} />
)}
</div>
);
</div>
)
export default PhotoViewer;
export default PhotoViewer;
+39 -42
View File
@@ -1,58 +1,55 @@
import PhotoViewer from "./PhotoViewer";
import {connect} from "react-redux";
import { connect } from "react-redux";
import env from "../../enviroment/envFrontEnd";
import React from "react";
import {resetPhotoID} from "../../actions/photoViewer";
import { resetPhotoID } from "../../actions/photoViewer";
import axios from "../../axiosInterceptor";
class PhotoViewerContainer extends React.Component {
constructor(props) {
super(props);
constructor(props) {
super(props);
this.state = {
image: "",
};
}
this.state = {
image: ""
}
}
closePhotoViewer = () => {
this.props.dispatch(resetPhotoID());
};
closePhotoViewer = () => {
componentDidMount = () => {
const config = {
responseType: "arraybuffer",
};
this.props.dispatch(resetPhotoID())
}
// TODO: Fix URL
const url = `http://localhost:5173/api/file-service/full-thumbnail/${this.props.photoID}`;
axios.get(url, config).then((response) => {
const imgFile = new Blob([response.data]);
const imgUrl = URL.createObjectURL(imgFile);
componentDidMount = () => {
this.setState(() => ({
...this.state,
image: imgUrl,
}));
});
};
const config = {
responseType: 'arraybuffer'
};
const url = this.props.isGoogle ? `/file-service-google/full-thumbnail/${this.props.photoID}`
: !this.props.isPersonal ? `/file-service/full-thumbnail/${this.props.photoID}` : `/file-service-personal/full-thumbnail/${this.props.photoID}`;
axios.get(url, config).then((response) => {
const imgFile = new Blob([response.data]);
const imgUrl = URL.createObjectURL(imgFile);
this.setState(() => ({
...this.state,
image: imgUrl
}))
})
}
render() {
return <PhotoViewer
closePhotoViewer={this.closePhotoViewer}
state={this.state}/>
}
render() {
return (
<PhotoViewer
closePhotoViewer={this.closePhotoViewer}
state={this.state}
/>
);
}
}
const connectStateToProp = (state) => ({
photoID: state.photoViewer.id,
isGoogle: state.photoViewer.isGoogle,
isPersonal: state.photoViewer.isPersonal,
})
photoID: state.photoViewer.id,
isGoogle: state.photoViewer.isGoogle,
isPersonal: state.photoViewer.isPersonal,
});
export default connect(connectStateToProp)(PhotoViewerContainer);
export default connect(connectStateToProp)(PhotoViewerContainer);