Fix(ish) multiwindow updates

This commit is contained in:
Gregory Schier
2023-03-29 11:15:37 -07:00
parent cd5ae6691c
commit b91d1b8b3c
4 changed files with 59 additions and 35 deletions

View File

@@ -1,5 +1,6 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { invoke } from '@tauri-apps/api';
import { appWindow } from '@tauri-apps/api/window';
import type { HttpRequest } from '../lib/models';
import { getRequest } from '../lib/store';
import { requestsQueryKey } from './useRequests';
@@ -20,6 +21,9 @@ export function useUpdateRequest(id: string | null) {
const request = await getRequest(id);
if (request === null) return;
// Sync updatedBy so that the UI doesn't think the update is coming from elsewhere
request.updatedBy = appWindow.label;
const newRequest = typeof v === 'function' ? v(request) : { ...request, ...v };
queryClient.setQueryData(
requestsQueryKey(request?.workspaceId),