From c08697efb2052f74806ae90297d3f9aebf8468bf Mon Sep 17 00:00:00 2001 From: talksik Date: Thu, 5 May 2022 10:25:11 -0500 Subject: [PATCH] handling creation smoothness and refetching --- packages/desktop/src/controller/index.tsx | 7 ++++++- packages/desktop/src/pages/terminal/newLine/index.tsx | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/desktop/src/controller/index.tsx b/packages/desktop/src/controller/index.tsx index 27f7304..383934c 100644 --- a/packages/desktop/src/controller/index.tsx +++ b/packages/desktop/src/controller/index.tsx @@ -2,6 +2,7 @@ import NirvanaApi, { ApiCalls } from "./nirvanaApi"; import { useMutation, useQuery } from "react-query"; import { $jwtToken } from "./recoil"; +import { queryClient } from "../pages/nirvanaApp"; import { useRecoilValue } from "recoil"; // ====== QUERIES @@ -50,5 +51,9 @@ export function useGetDmByUserId() { } export function useCreateLine() { - return useMutation(ApiCalls.createLine); + return useMutation(ApiCalls.createLine, { + onSuccess: (res, req) => { + queryClient.invalidateQueries(["USER_LINES"]); + }, + }); } diff --git a/packages/desktop/src/pages/terminal/newLine/index.tsx b/packages/desktop/src/pages/terminal/newLine/index.tsx index bdaf9c2..e85353a 100644 --- a/packages/desktop/src/pages/terminal/newLine/index.tsx +++ b/packages/desktop/src/pages/terminal/newLine/index.tsx @@ -98,7 +98,7 @@ export default function NewLineModal({ toast.success("created line!"); // handle close once the new line is created - // handleClose(); + handleClose(); } catch (error) { toast.error(error); console.error(error);