mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 17:48:30 +02:00
Messages are flowing!
This commit is contained in:
@@ -69,6 +69,10 @@ export function GlobalHooks() {
|
|||||||
? cookieJarsQueryKey(payload)
|
? cookieJarsQueryKey(payload)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
const pushToFront = (['http_response', 'grpc_connection'] as Model['model'][]).includes(
|
||||||
|
payload.model,
|
||||||
|
);
|
||||||
|
|
||||||
if (queryKey === null) {
|
if (queryKey === null) {
|
||||||
console.log('Unrecognized created model:', payload);
|
console.log('Unrecognized created model:', payload);
|
||||||
return;
|
return;
|
||||||
@@ -76,7 +80,9 @@ export function GlobalHooks() {
|
|||||||
|
|
||||||
if (!shouldIgnoreModel(payload)) {
|
if (!shouldIgnoreModel(payload)) {
|
||||||
// Order newest first
|
// Order newest first
|
||||||
queryClient.setQueryData<Model[]>(queryKey, (values) => [payload, ...(values ?? [])]);
|
queryClient.setQueryData<Model[]>(queryKey, (values) =>
|
||||||
|
pushToFront ? [payload, ...(values ?? [])] : [...(values ?? []), payload],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||||
import { invoke } from '@tauri-apps/api';
|
import { invoke } from '@tauri-apps/api';
|
||||||
import type { UnlistenFn } from '@tauri-apps/api/event';
|
import { emit } from '@tauri-apps/api/event';
|
||||||
import { emit, listen } from '@tauri-apps/api/event';
|
import { useEffect, useState } from 'react';
|
||||||
import { useEffect, useRef, useState } from 'react';
|
|
||||||
import type { GrpcConnection, GrpcMessage, GrpcRequest } from '../lib/models';
|
import type { GrpcConnection, GrpcMessage, GrpcRequest } from '../lib/models';
|
||||||
import { useKeyValue } from './useKeyValue';
|
import { useKeyValue } from './useKeyValue';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user