Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: 🚸 Type: Refactoring, Improvement | Title: Refactoring file upload and handling in the application #12

Merged
merged 1 commit into from
Dec 23, 2023

Conversation

RicardoGEsteves
Copy link
Owner

Description:
The changes mainly focus on refactoring the way files are uploaded and handled in the application. The changes are made in three files: 'app/api/uploadthing/core.ts', 'components/rich-text-editor/editor-setup.tsx', and 'lib/uploadthing.ts'. The changes include modifying the middleware function in 'core.ts', updating the file upload handling in 'editor-setup.tsx', and adding a new function 'uploadFiles' in 'uploadthing.ts'.

Main Files Walkthrough:

  • app/api/uploadthing/core.ts: The middleware function in 'ourFileRouter' object has been modified. The 'getToken' function now only takes 'req' as a parameter, removing the 'secret' parameter. The 'onUploadComplete' function has been simplified and now it doesn't log any information or return any data.
  • components/rich-text-editor/editor-setup.tsx: The 'handleUpload' function has been renamed to 'handleUploadFile' and its implementation has been updated. It now uses the 'uploadFiles' function from 'uploadthing.ts' to upload the files. Error handling has been added to the function. The 'uploadFile' property in the 'useBlockNote' function now uses the updated 'handleUploadFile' function. - lib/uploadthing.ts: A new function 'uploadFiles' has been added by using 'generateReactHelpers' function from '@uploadthing/react/hooks'. This function is exported and used in 'editor-setup.tsx' for file upload.

Improvement on text editor files upload. Now users have a much better experience.

…ad and handling in the application

Description:
The changes mainly focus on refactoring the way files are uploaded and handled in the application. The changes are made in three files: 'app/api/uploadthing/core.ts', 'components/rich-text-editor/editor-setup.tsx', and 'lib/uploadthing.ts'. The changes include modifying the middleware function in 'core.ts', updating the file upload handling in 'editor-setup.tsx', and adding a new function 'uploadFiles' in 'uploadthing.ts'.

Main Files Walkthrough:
- app/api/uploadthing/core.ts: The middleware function in 'ourFileRouter' object has been modified. The 'getToken' function now only takes 'req' as a parameter, removing the 'secret' parameter. The 'onUploadComplete' function has been simplified and now it doesn't log any information or return any data.
- components/rich-text-editor/editor-setup.tsx: The 'handleUpload' function has been renamed to 'handleUploadFile' and its implementation has been updated. It now uses the 'uploadFiles' function from 'uploadthing.ts' to upload the files. Error handling has been added to the function. The 'uploadFile' property in the 'useBlockNote' function now uses the updated 'handleUploadFile' function. -  lib/uploadthing.ts: A new function 'uploadFiles' has been added by using 'generateReactHelpers' function from '@uploadthing/react/hooks'. This function is exported and used in 'editor-setup.tsx' for file upload.

Improvement on text editor files upload. Now users have a much better experience.
@RicardoGEsteves RicardoGEsteves merged commit f2384e8 into main Dec 23, 2023
3 checks passed
@RicardoGEsteves RicardoGEsteves deleted the create-subSpreadIt-post branch December 23, 2023 14:01
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.

1 participant