mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-07 22:14:03 -05:00
fix: cleanup orphaned localStorage entries when conversation is deleted
When a conversation is deleted, the localStorage entries for that conversation's UI state (right panel visibility, selected tab, unpinned tabs) were not being cleaned up, leading to accumulation of orphaned data. This adds a cleanup function that removes these localStorage entries in the onSuccess callback of the delete mutation. Fixes: APP-306 Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import ConversationService from "#/api/conversation-service/conversation-service.api";
|
||||
|
||||
const cleanupConversationLocalStorage = (conversationId: string) => {
|
||||
const keysToRemove = [
|
||||
`conversation-right-panel-shown-${conversationId}`,
|
||||
`conversation-selected-tab-${conversationId}`,
|
||||
`conversation-unpinned-tabs-${conversationId}`,
|
||||
];
|
||||
keysToRemove.forEach((key) => localStorage.removeItem(key));
|
||||
};
|
||||
|
||||
export const useDeleteConversation = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -32,6 +41,9 @@ export const useDeleteConversation = () => {
|
||||
);
|
||||
}
|
||||
},
|
||||
onSuccess: (_, variables) => {
|
||||
cleanupConversationLocalStorage(variables.conversationId);
|
||||
},
|
||||
onSettled: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["user", "conversations"] });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user