-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: optimize deletion of messages (#2714)
* feat: optimize deletion of messages in SessionView component This commit optimizes the deletion of messages in the SessionView component by using the useDeleteMessages hook from the API queries. It replaces the useRemoveMessages hook that was previously used. The new implementation handles the deletion of messages more efficiently and provides better error handling. The selectedRows state is updated after successful deletion, and a success message is displayed to the user. In case of an error, an error message is shown. Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> * feat: optimize deletion of messages in SessionView component This commit optimizes the deletion of messages in the SessionView component by using the useDeleteMessages hook from the API queries. It replaces the useRemoveMessages hook that was previously used. The new implementation handles the deletion of messages more efficiently and provides better error handling. The selectedRows state is updated after successful deletion, and a success message is displayed to the user. In case of an error, an error message is shown. Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> * refactor: optimize deletion of messages in SessionView component This commit optimizes the deletion of messages in the SessionView component by using the useDeleteMessages hook from the API queries. It replaces the useRemoveMessages hook that was previously used. The new implementation handles the deletion of messages more efficiently and provides better error handling. The selectedRows state is updated after successful deletion, and a success message is displayed to the user. In case of an error, an error message is shown. * [autofix.ci] apply automated fixes --------- Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Lucas Oliveira <[email protected]> Co-authored-by: Lucas Oliveira <[email protected]>
- Loading branch information
1 parent
51346b1
commit 4a9376a
Showing
6 changed files
with
82 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useMutationFunctionType } from "@/types/api"; | ||
import { UseMutationResult } from "@tanstack/react-query"; | ||
import { api } from "../../api"; | ||
import { getURL } from "../../helpers/constants"; | ||
import { UseRequestProcessor } from "../../services/request-processor"; | ||
|
||
interface DeleteMessagesParams { | ||
ids: string[]; | ||
} | ||
|
||
export const useDeleteMessages: useMutationFunctionType< | ||
DeleteMessagesParams | ||
> = (options?) => { | ||
const { mutate } = UseRequestProcessor(); | ||
|
||
const deleteMessage = async ({ ids }: DeleteMessagesParams): Promise<any> => { | ||
const response = await api.delete(`${getURL("MESSAGES")}`, { | ||
data: ids, | ||
}); | ||
|
||
return response.data; | ||
}; | ||
|
||
const mutation: UseMutationResult< | ||
DeleteMessagesParams, | ||
any, | ||
DeleteMessagesParams | ||
> = mutate(["useDeleteMessages"], deleteMessage, options); | ||
|
||
return mutation; | ||
}; |
29 changes: 0 additions & 29 deletions
29
src/frontend/src/modals/IOModal/components/SessionView/hooks/index.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
src/frontend/src/pages/SettingsPage/pages/messagesPage/hooks/use-remove-messages.tsx
This file was deleted.
Oops, something went wrong.