mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-19 07:54:23 +01:00
Fix(ish) multiwindow updates
This commit is contained in:
@@ -125,8 +125,12 @@ export const RequestPane = memo(function RequestPane({ style, fullHeight, classN
|
||||
[],
|
||||
);
|
||||
|
||||
const forceUpdateKey =
|
||||
activeRequest?.updatedBy === appWindow.label ? undefined : activeRequest?.updatedAt;
|
||||
const forceUpdateKey = useMemo(() => {
|
||||
if (activeRequest == null) return undefined;
|
||||
if (activeRequest.updatedBy === appWindow.label) return appWindow.label;
|
||||
return `${appWindow.label}::${activeRequest?.updatedAt}`;
|
||||
}, [activeRequest]);
|
||||
console.log('FORCE UPDATE KEY', forceUpdateKey);
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -2,7 +2,7 @@ export interface BaseModel {
|
||||
readonly id: string;
|
||||
readonly createdAt: string;
|
||||
readonly updatedAt: string;
|
||||
readonly updatedBy: string;
|
||||
updatedBy: string;
|
||||
}
|
||||
|
||||
export interface Workspace extends BaseModel {
|
||||
|
||||
Reference in New Issue
Block a user