Open-source and local-first Slack and Notion alternative that puts you in control of your data
TypeScript chatchat-applicationcrdteditorelectronknowledge-baselocal-firstnotionnotion-alternativerealtime-collaborationself-hostedslacksqliteteam-collaborationwikiyjs
Fix queries and mutations for chat
Hakan Shehu736ffc441729
diff --git a/desktop/src/main/handlers/mutations/chat-create.ts b/desktop/src/main/handlers/mutations/chat-create.tsindex dfd0ac0f..8772123e 100644--- a/desktop/src/main/handlers/mutations/chat-create.ts+++ b/desktop/src/main/handlers/mutations/chat-create.ts@@ -25,8 +25,8 @@ export class ChatCreateMutationHandlerSELECT idFROM nodesWHERE type = ${NodeTypes.Chat}- AND json_extract(attributes, '$.collaborators.${input.userId}') = 'owner'- AND json_extract(attributes, '$.collaborators.${input.otherUserId}') = 'owner'+ AND json_extract(attributes, '$.collaborators.${sql.raw(input.userId)}') = 'owner'+ AND json_extract(attributes, '$.collaborators.${sql.raw(input.otherUserId)}') = 'owner'`.compile(workspaceDatabase);const existingChats = await workspaceDatabase.executeQuery(query);diff --git a/desktop/src/main/handlers/queries/chat-get.ts b/desktop/src/main/handlers/queries/chat-get.tsindex 4895acfe..34c9a9ac 100644--- a/desktop/src/main/handlers/queries/chat-get.ts+++ b/desktop/src/main/handlers/queries/chat-get.ts@@ -108,9 +108,9 @@ export class ChatGetQueryHandler implements QueryHandler<ChatGetQueryInput> {return [];}- const collaboratorIds = Object.keys(attributes.collaborators);+ const collaboratorIds: string[] = [];if (attributes.collaborators) {- for (const collaboratorId of collaboratorIds) {+ for (const collaboratorId of Object.keys(attributes.collaborators)) {if (collaboratorId === input.userId) {continue;}@@ -129,8 +129,7 @@ export class ChatGetQueryHandler implements QueryHandler<ChatGetQueryInput> {.selectAll().execute();- const nodes = [chat, ...collaborators];- return nodes;+ return collaborators;}private buildChat = (