mirror of
https://github.com/colanode/colanode.git
synced 2025-12-29 00:25:03 +01:00
Add query change handlers for workspace delete event
This commit is contained in:
@@ -27,6 +27,16 @@ export class FileListQueryHandler implements QueryHandler<FileListQueryInput> {
|
||||
input: FileListQueryInput,
|
||||
output: FileNode[]
|
||||
): Promise<ChangeCheckResult<FileListQueryInput>> {
|
||||
if (
|
||||
event.type === 'workspace_deleted' &&
|
||||
event.workspace.userId === input.userId
|
||||
) {
|
||||
return {
|
||||
hasChanges: true,
|
||||
result: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
event.type === 'node_created' &&
|
||||
event.userId === input.userId &&
|
||||
|
||||
@@ -30,6 +30,16 @@ export class MessageListQueryHandler
|
||||
input: MessageListQueryInput,
|
||||
output: MessageNode[]
|
||||
): Promise<ChangeCheckResult<MessageListQueryInput>> {
|
||||
if (
|
||||
event.type === 'workspace_deleted' &&
|
||||
event.workspace.userId === input.userId
|
||||
) {
|
||||
return {
|
||||
hasChanges: true,
|
||||
result: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
event.type === 'node_created' &&
|
||||
event.userId === input.userId &&
|
||||
|
||||
@@ -19,6 +19,16 @@ export class NodeChildrenGetQueryHandler
|
||||
input: NodeChildrenGetQueryInput,
|
||||
output: Node[]
|
||||
): Promise<ChangeCheckResult<NodeChildrenGetQueryInput>> {
|
||||
if (
|
||||
event.type === 'workspace_deleted' &&
|
||||
event.workspace.userId === input.userId
|
||||
) {
|
||||
return {
|
||||
hasChanges: true,
|
||||
result: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
event.type === 'node_created' &&
|
||||
event.userId === input.userId &&
|
||||
|
||||
@@ -17,6 +17,16 @@ export class NodeGetQueryHandler implements QueryHandler<NodeGetQueryInput> {
|
||||
input: NodeGetQueryInput,
|
||||
_: Node | null
|
||||
): Promise<ChangeCheckResult<NodeGetQueryInput>> {
|
||||
if (
|
||||
event.type === 'workspace_deleted' &&
|
||||
event.workspace.userId === input.userId
|
||||
) {
|
||||
return {
|
||||
hasChanges: true,
|
||||
result: null,
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
event.type === 'node_updated' &&
|
||||
event.userId === input.userId &&
|
||||
|
||||
@@ -20,6 +20,16 @@ export class NodeTreeGetQueryHandler
|
||||
input: NodeTreeGetQueryInput,
|
||||
output: Node[]
|
||||
): Promise<ChangeCheckResult<NodeTreeGetQueryInput>> {
|
||||
if (
|
||||
event.type === 'workspace_deleted' &&
|
||||
event.workspace.userId === input.userId
|
||||
) {
|
||||
return {
|
||||
hasChanges: true,
|
||||
result: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (event.type === 'node_updated' && event.userId === input.userId) {
|
||||
const node = output.find((node) => node.id === event.node.id);
|
||||
if (node) {
|
||||
|
||||
@@ -39,6 +39,16 @@ export class RecordListQueryHandler
|
||||
input: RecordListQueryInput,
|
||||
output: RecordNode[]
|
||||
): Promise<ChangeCheckResult<RecordListQueryInput>> {
|
||||
if (
|
||||
event.type === 'workspace_deleted' &&
|
||||
event.workspace.userId === input.userId
|
||||
) {
|
||||
return {
|
||||
hasChanges: true,
|
||||
result: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
event.type === 'node_created' &&
|
||||
event.userId === input.userId &&
|
||||
|
||||
@@ -25,6 +25,16 @@ export class UserSearchQueryHandler
|
||||
input: UserSearchQueryInput,
|
||||
_: UserNode[]
|
||||
): Promise<ChangeCheckResult<UserSearchQueryInput>> {
|
||||
if (
|
||||
event.type === 'workspace_deleted' &&
|
||||
event.workspace.userId === input.userId
|
||||
) {
|
||||
return {
|
||||
hasChanges: true,
|
||||
result: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
event.type === 'node_created' &&
|
||||
event.userId === input.userId &&
|
||||
|
||||
@@ -22,6 +22,16 @@ export class WorkspaceUserListQueryHandler
|
||||
input: WorkspaceUserListQueryInput,
|
||||
output: UserNode[]
|
||||
): Promise<ChangeCheckResult<WorkspaceUserListQueryInput>> {
|
||||
if (
|
||||
event.type === 'workspace_deleted' &&
|
||||
event.workspace.userId === input.userId
|
||||
) {
|
||||
return {
|
||||
hasChanges: true,
|
||||
result: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
event.type === 'node_created' &&
|
||||
event.userId === input.userId &&
|
||||
|
||||
Reference in New Issue
Block a user