Rename a query

This commit is contained in:
Hakan Shehu
2024-11-13 12:00:41 +01:00
parent af4f014a32
commit c40522fccb
9 changed files with 20 additions and 20 deletions

View File

@@ -11,7 +11,7 @@ import { RecordListQueryHandler } from '@/main/handlers/queries/record-list';
import { FileListQueryHandler } from '@/main/handlers/queries/file-list';
import { EmojisGetQueryHandler } from '@/main/handlers/queries/emojis-get';
import { IconsGetQueryHandler } from '@/main/handlers/queries/icons-get';
import { NodeWithAncestorsGetQueryHandler } from '@/main/handlers/queries/node-with-ancestors-get';
import { NodeTreeGetQueryHandler } from '@/main/handlers/queries/node-tree-get';
import { NodeChildrenGetQueryHandler } from '@/main/handlers/queries/node-children-get';
type QueryHandlerMap = {
@@ -30,6 +30,6 @@ export const queryHandlerMap: QueryHandlerMap = {
file_list: new FileListQueryHandler(),
emojis_get: new EmojisGetQueryHandler(),
icons_get: new IconsGetQueryHandler(),
node_with_ancestors_get: new NodeWithAncestorsGetQueryHandler(),
node_tree_get: new NodeTreeGetQueryHandler(),
node_children_get: new NodeChildrenGetQueryHandler(),
};

View File

@@ -8,15 +8,15 @@ import {
QueryResult,
} from '@/main/types';
import { isEqual } from 'lodash-es';
import { NodeWithAncestorsGetQueryInput } from '@/operations/queries/node-with-ancestors-get';
import { NodeTreeGetQueryInput } from '@/operations/queries/node-tree-get';
import { fetchNodeAncestors } from '@/main/utils';
export class NodeWithAncestorsGetQueryHandler
implements QueryHandler<NodeWithAncestorsGetQueryInput>
export class NodeTreeGetQueryHandler
implements QueryHandler<NodeTreeGetQueryInput>
{
public async handleQuery(
input: NodeWithAncestorsGetQueryInput
): Promise<QueryResult<NodeWithAncestorsGetQueryInput>> {
input: NodeTreeGetQueryInput
): Promise<QueryResult<NodeTreeGetQueryInput>> {
const rows = await this.fetchNodes(input);
return {
@@ -29,9 +29,9 @@ export class NodeWithAncestorsGetQueryHandler
public async checkForChanges(
changes: MutationChange[],
input: NodeWithAncestorsGetQueryInput,
input: NodeTreeGetQueryInput,
state: Record<string, any>
): Promise<ChangeCheckResult<NodeWithAncestorsGetQueryInput>> {
): Promise<ChangeCheckResult<NodeTreeGetQueryInput>> {
if (
!changes.some(
(change) =>
@@ -64,7 +64,7 @@ export class NodeWithAncestorsGetQueryHandler
}
private async fetchNodes(
input: NodeWithAncestorsGetQueryInput
input: NodeTreeGetQueryInput
): Promise<SelectNode[]> {
const workspaceDatabase = await databaseManager.getWorkspaceDatabase(
input.userId

View File

@@ -1,15 +1,15 @@
import { Node } from '@colanode/core';
export type NodeWithAncestorsGetQueryInput = {
type: 'node_with_ancestors_get';
export type NodeTreeGetQueryInput = {
type: 'node_tree_get';
nodeId: string;
userId: string;
};
declare module '@/operations/queries' {
interface QueryMap {
node_with_ancestors_get: {
input: NodeWithAncestorsGetQueryInput;
node_tree_get: {
input: NodeTreeGetQueryInput;
output: Node[];
};
}

View File

@@ -11,7 +11,7 @@ interface ChannelContainerProps {
export const ChannelContainer = ({ nodeId }: ChannelContainerProps) => {
const workspace = useWorkspace();
const { data, isPending } = useQuery({
type: 'node_with_ancestors_get',
type: 'node_tree_get',
nodeId,
userId: workspace.userId,
});

View File

@@ -11,7 +11,7 @@ interface DatabaseContainerProps {
export const DatabaseContainer = ({ nodeId }: DatabaseContainerProps) => {
const workspace = useWorkspace();
const { data, isPending } = useQuery({
type: 'node_with_ancestors_get',
type: 'node_tree_get',
nodeId,
userId: workspace.userId,
});

View File

@@ -11,7 +11,7 @@ interface FileContainerProps {
export const FileContainer = ({ nodeId }: FileContainerProps) => {
const workspace = useWorkspace();
const { data, isPending } = useQuery({
type: 'node_with_ancestors_get',
type: 'node_tree_get',
nodeId,
userId: workspace.userId,
});

View File

@@ -12,7 +12,7 @@ export const FolderContainer = ({ nodeId }: FolderContainerProps) => {
const workspace = useWorkspace();
const { data, isPending } = useQuery({
type: 'node_with_ancestors_get',
type: 'node_tree_get',
nodeId,
userId: workspace.userId,
});

View File

@@ -11,7 +11,7 @@ interface PageContainerProps {
export const PageContainer = ({ nodeId }: PageContainerProps) => {
const workspace = useWorkspace();
const { data, isPending } = useQuery({
type: 'node_with_ancestors_get',
type: 'node_tree_get',
nodeId,
userId: workspace.userId,
});

View File

@@ -11,7 +11,7 @@ interface RecordContainerProps {
export const RecordContainer = ({ nodeId }: RecordContainerProps) => {
const workspace = useWorkspace();
const { data, isPending } = useQuery({
type: 'node_with_ancestors_get',
type: 'node_tree_get',
nodeId,
userId: workspace.userId,
});