-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[PE-93] refactor: accept generic function to search mentions #6249
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,7 +21,9 @@ import { useProjectInbox } from "@/hooks/store"; | |||||||||||||||
import { usePlatformOS } from "@/hooks/use-platform-os"; | ||||||||||||||||
// services | ||||||||||||||||
import { FileService } from "@/services/file.service"; | ||||||||||||||||
import { ProjectService } from "@/services/project"; | ||||||||||||||||
const fileService = new FileService(); | ||||||||||||||||
const projectService = new ProjectService(); | ||||||||||||||||
|
||||||||||||||||
type TInboxIssueDescription = { | ||||||||||||||||
containerClassName?: string; | ||||||||||||||||
|
@@ -72,6 +74,9 @@ export const InboxIssueDescription: FC<TInboxIssueDescription> = observer((props | |||||||||||||||
dragDropEnabled={false} | ||||||||||||||||
onChange={(_description: object, description_html: string) => handleData("description_html", description_html)} | ||||||||||||||||
placeholder={getDescriptionPlaceholder} | ||||||||||||||||
searchMentionCallback={async (payload) => | ||||||||||||||||
await projectService.searchEntity(workspaceSlug?.toString() ?? "", projectId?.toString() ?? "", payload) | ||||||||||||||||
} | ||||||||||||||||
Comment on lines
+77
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve null safety in searchMentionCallback The current implementation uses optional chaining with toString() which could still result in "undefined" being passed as a string. Consider this safer implementation: - searchMentionCallback={async (payload) =>
- await projectService.searchEntity(workspaceSlug?.toString() ?? "", projectId?.toString() ?? "", payload)
- }
+ searchMentionCallback={async (payload) => {
+ if (!workspaceSlug || !projectId) throw new Error("Workspace slug and project ID are required");
+ return await projectService.searchEntity(workspaceSlug.toString(), projectId.toString(), payload);
+ }} 📝 Committable suggestion
Suggested change
|
||||||||||||||||
containerClassName={containerClassName} | ||||||||||||||||
onEnterKeyPress={onEnterKeyPress} | ||||||||||||||||
tabIndex={getIndex("description_html")} | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider dependency injection for services
Creating service instances at the module level can lead to:
Consider injecting the service through props or a dependency injection container: