mirror of
https://github.com/colanode/colanode.git
synced 2026-05-18 05:05:03 +02:00
Fix workspace update (#310)
This commit is contained in:
@@ -12,9 +12,7 @@ import { AppService } from '@colanode/client/services/app-service';
|
||||
import { Workspace } from '@colanode/client/types';
|
||||
import { WorkspaceUpdateInput } from '@colanode/core';
|
||||
|
||||
export class WorkspaceUpdateMutationHandler
|
||||
implements MutationHandler<WorkspaceUpdateMutationInput>
|
||||
{
|
||||
export class WorkspaceUpdateMutationHandler implements MutationHandler<WorkspaceUpdateMutationInput> {
|
||||
private readonly app: AppService;
|
||||
|
||||
constructor(app: AppService) {
|
||||
@@ -24,15 +22,6 @@ export class WorkspaceUpdateMutationHandler
|
||||
async handleMutation(
|
||||
input: WorkspaceUpdateMutationInput
|
||||
): Promise<WorkspaceUpdateMutationOutput> {
|
||||
const accountService = this.app.getAccount(input.userId);
|
||||
|
||||
if (!accountService) {
|
||||
throw new MutationError(
|
||||
MutationErrorCode.AccountNotFound,
|
||||
'Account not found or has been logged out.'
|
||||
);
|
||||
}
|
||||
|
||||
const workspaceService = this.app.getWorkspace(input.userId);
|
||||
if (!workspaceService) {
|
||||
throw new MutationError(
|
||||
@@ -48,8 +37,8 @@ export class WorkspaceUpdateMutationHandler
|
||||
avatar: input.avatar,
|
||||
};
|
||||
|
||||
const response = await accountService.client
|
||||
.patch(`v1/workspaces/${input.id}`, {
|
||||
const response = await workspaceService.account.client
|
||||
.patch(`v1/workspaces/${workspaceService.workspace.workspaceId}`, {
|
||||
json: body,
|
||||
})
|
||||
.json<Workspace>();
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
export type WorkspaceUpdateMutationInput = {
|
||||
type: 'workspace.update';
|
||||
id: string;
|
||||
userId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
avatar: string | null;
|
||||
userId: string;
|
||||
};
|
||||
|
||||
export type WorkspaceUpdateMutationOutput = {
|
||||
|
||||
@@ -20,15 +20,13 @@ export const WorkspaceSettingsContainer = () => {
|
||||
(q) =>
|
||||
q
|
||||
.from({ workspaces: collections.workspaces })
|
||||
.where(({ workspaces }) =>
|
||||
eq(workspaces.accountId, workspace.accountId)
|
||||
)
|
||||
.where(({ workspaces }) => eq(workspaces.userId, workspace.userId))
|
||||
.select(({ workspaces }) => ({
|
||||
name: workspaces.name,
|
||||
description: workspaces.description,
|
||||
avatar: workspaces.avatar,
|
||||
})),
|
||||
[workspace.accountId]
|
||||
[workspace.userId]
|
||||
);
|
||||
|
||||
const currentWorkspace = currentWorkspaceQuery.data?.[0];
|
||||
@@ -57,7 +55,6 @@ export const WorkspaceSettingsContainer = () => {
|
||||
mutate({
|
||||
input: {
|
||||
type: 'workspace.update',
|
||||
id: workspace.workspaceId,
|
||||
userId: workspace.userId,
|
||||
name: values.name,
|
||||
description: values.description,
|
||||
|
||||
Reference in New Issue
Block a user