Skip to content

Conversation

Tonybodo
Copy link

@Tonybodo Tonybodo commented May 16, 2023

closes #400
First release for Annotation Service.

We know the Pull Request is packed with features, but we value your feedback and would appreciate any input.

Glhf :)

Copy link
Contributor

@jonaskordt jonaskordt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey everyone. Great to see how much progress you have made already!

I didn't point out the same thing multiple times even if I saw it multiple times. Please try to find other occurrences of the same thing when you see my comments.

Here are a couple of things that I saw a lot:

  1. Some exports are missing resulting in imports with lots of depth.
  2. Sometimes you don't use useCallback enough. (Search for ={() => across the codebase, but also look for functions that you just create within components.)
  3. You should use translation data instead of replacing underscores manually.
  4. Adding more dedicated props files would make the code a lot cleaner.
  5. You still have a couple // TODO and // Fix comments that you might want to take a look at before merging.
  6. You should use useQuery instead of callbacks that fetch something which are called from useEffect (you mostly do this already).

Comment on lines 213 to 251
const loadImagesAndAnnotations = () => {
async function asyncfunc() {
if (store?.editor.activeDocument?.layers.length !== 0) {
return store?.destroyReload();
}
const fileTransfer = new DataTransfer();
const imageIdToOpen = searchParams.get("imageId");
if (imageIdToOpen) {
try {
const imageFile = await fetchImageFile(imageIdToOpen);
fileTransfer.items.add(imageFile);
} catch (error) {
store?.setError({
titleTx: "import-error",
descriptionTx: "image-open-error",
});
}
}
const annotationIdToOpen = searchParams.get("annotationId");
if (annotationIdToOpen) {
try {
const annotationFile = await fetchAnnotationFile(
annotationIdToOpen,
);
fileTransfer.items.add(annotationFile);
} catch (error) {
store?.setError({
titleTx: "import-error",
descriptionTx: "annotation-open-error",
});
}
}
if (store && fileTransfer.files.length) {
importFilesToDocument(fileTransfer.files, store);
}
}
asyncfunc();
};
useEffect(loadImagesAndAnnotations, [searchParams, store]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern of creating a callback that fetches something and then calling it form a useEffect is quite dirty. Instead you can use useQuery.

Copy link
Contributor

@PaulBrachmann PaulBrachmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jonaskordt for doing the heavy lifting in terms of the review already!

I can only agree, it's quite impressive what you came up with and how well you integrated your extensions into the existing codebase.

I added a few more comments. -- And while we're at those, please make sure you use // Sentence case in your comments consistently (if you don't have a good reason not to).

Keep up the great work!

import { Job } from "../types";
import { hubBaseUrl } from "./hub-base-url";

const getJobsBy = async (projectId: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably call these getJobsByProject, etc.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be refactored in #433

Comment on lines +92 to +99
return {
isDeleteProjectsError: isError,
isDeleteProjectsIdle: isIdle,
isDeleteProjectsLoading: isLoading,
isDeleteProjectsPaused: isPaused,
isDeleteProjectsSuccess: isSuccess,
deleteProjects: mutate,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you invent your own interface here?
I think it might be cleaner to stick to the one provided by react-query and use your hooks like this:

const deleteProjects = useDeleteProjectsMutation();
...
deleteProjects.mutate();

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be refactored in #433

@TimRiedel
Copy link
Contributor

TimRiedel commented May 26, 2023

Hi Jonas and Paul, thanks a lot that you took the time to review this gigantic PR! The comments are very helpful and we will try to implement them within the next week.

richartkeil and others added 30 commits July 25, 2023 10:45
feat: add dragndrop layergroup ui
fix: layer group ui bug with incorrect preview
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merge first release of annotation backend into develop
9 participants