Adjust groups (#31)

* Messages groups & threads
This commit is contained in:
Kristina
2025-02-27 11:14:55 +04:00
committed by GitHub
parent 197c3b4c27
commit c7184a2bb0
68 changed files with 2624 additions and 1527 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hcengineering/communication-client-sqlite",
"version": "0.1.9",
"version": "0.1.47",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "./types/index.d.ts",
+24 -6
View File
@@ -13,7 +13,10 @@ import {
type Notification,
type Attachment,
type Reaction,
type WorkspaceID
type WorkspaceID,
type FindMessagesGroupsParams,
type MessagesGroup,
PatchType
} from '@hcengineering/communication-types'
import {
type Client,
@@ -24,7 +27,8 @@ import {
} from '@hcengineering/communication-sdk-types'
import { createDbAdapter as createSqliteDbAdapter } from '@hcengineering/communication-sqlite-wasm'
class DbClient implements Client {
//TODO: FIXME
class DbClient {
onEvent: (event: ResponseEvent) => void = () => {}
constructor(
@@ -61,10 +65,14 @@ class DbClient implements Client {
this.onEvent({ type: ResponseEventType.MessageRemoved, message, card })
}
async createPatch(card: CardID, message: MessageID, content: RichText, creator: SocialID): Promise<void> {
async updateMessage(card: CardID, message: MessageID, content: RichText, creator: SocialID): Promise<void> {
const created = new Date()
await this.db.createPatch(card, message, content, creator, created)
this.onEvent({ type: ResponseEventType.PatchCreated, card, patch: { message, content, creator, created } })
await this.db.createPatch(card, message, PatchType.update, content, creator, created)
this.onEvent({
type: ResponseEventType.PatchCreated,
card,
patch: { message, type: PatchType.update, content, creator, created }
})
}
async createReaction(card: CardID, message: MessageID, reaction: string, creator: SocialID): Promise<void> {
@@ -98,6 +106,10 @@ class DbClient implements Client {
return rawMessages.map((it) => this.toMessage(it))
}
async findMessagesGroups(params: FindMessagesGroupsParams): Promise<MessagesGroup[]> {
return await this.db.findMessagesGroups(params)
}
async findMessage(params: FindMessagesParams): Promise<Message | undefined> {
return (await this.findMessages({ ...params, limit: 1 }))[0]
}
@@ -158,11 +170,17 @@ class DbClient implements Client {
return await this.db.findContexts(params, [this.personalWorkspace])
}
//eslint-disable-next-line @typescript-eslint/no-unused-vars
async findNotifications(params: FindNotificationsParams): Promise<Notification[]> {
//TODO: should we filter by workspace?
return await this.db.findNotifications(params, this.personalWorkspace)
}
//eslint-disable-next-line @typescript-eslint/no-unused-vars
async createThread(card: CardID, message: MessageID, thread: CardID, created: Date): Promise<void> {
//TODO: implement
}
async unsubscribeQuery() {
//ignore
}
@@ -178,5 +196,5 @@ export async function getSqliteClient(
dbUrl = 'file:communication.sqlite3?vfs=opfs'
): Promise<Client> {
const db = await createSqliteDbAdapter(dbUrl)
return new DbClient(db, workspace, personalWorkspace)
return new DbClient(db, workspace, personalWorkspace) as unknown as Client
}