diff --git a/.nvmrc b/.nvmrc index 2bd5a0a..db49bb1 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -22 +22.22.2 diff --git a/packages/im/src/db/ConversationModel.ts b/packages/im/src/db/ConversationModel.ts index 4faa8f4..3b27e02 100644 --- a/packages/im/src/db/ConversationModel.ts +++ b/packages/im/src/db/ConversationModel.ts @@ -4,7 +4,7 @@ import { field, date } from '@nozbe/watermelondb/decorators' export class ConversationModel extends Model { static table = 'im_conversations' - @field('app_id') appKey!: string + @field('app_key') appKey!: string @field('target_id') targetId!: string @field('chat_type') chatType!: string @field('last_msg_id') lastMsgId!: string | null diff --git a/packages/im/src/db/ImDatabase.ts b/packages/im/src/db/ImDatabase.ts index 250aa17..349c58c 100644 --- a/packages/im/src/db/ImDatabase.ts +++ b/packages/im/src/db/ImDatabase.ts @@ -91,7 +91,7 @@ export const ImDatabase = { // upsert conversation — preserve isMuted/isPinned on update const convs = await db .get('im_conversations') - .query(Q.where('app_id', msg.appKey), Q.where('target_id', msg.toId)) + .query(Q.where('app_key', msg.appKey), Q.where('target_id', msg.toId)) .fetch() const msgTime = new Date(msg.createdAt).getTime() @@ -132,7 +132,7 @@ export const ImDatabase = { const db = getDb() const messages = await db .get('im_messages') - .query(Q.where('app_id', appKey), Q.where('server_id', messageId)) + .query(Q.where('app_key', appKey), Q.where('server_id', messageId)) .fetch() if (messages.length === 0) return @@ -149,7 +149,7 @@ export const ImDatabase = { const conversations = await db .get('im_conversations') - .query(Q.where('app_id', appKey), Q.where('target_id', message.toId)) + .query(Q.where('app_key', appKey), Q.where('target_id', message.toId)) .fetch() if (conversations.length > 0) { @@ -182,7 +182,7 @@ export const ImDatabase = { return db .get('im_conversations') .query( - Q.where('app_id', appKey), + Q.where('app_key', appKey), Q.sortBy('last_msg_time', Q.desc), ) .fetch() @@ -192,7 +192,7 @@ export const ImDatabase = { const db = getDb() const convs = await db .get('im_conversations') - .query(Q.where('app_id', appKey), Q.where('target_id', targetId)) + .query(Q.where('app_key', appKey), Q.where('target_id', targetId)) .fetch() if (convs.length > 0) { await db.write(async () => { @@ -206,7 +206,7 @@ export const ImDatabase = { const db = getDb() const convs = await db .get('im_conversations') - .query(Q.where('app_id', appKey), Q.where('target_id', targetId)) + .query(Q.where('app_key', appKey), Q.where('target_id', targetId)) .fetch() if (convs.length > 0) { await db.write(async () => { @@ -227,7 +227,7 @@ export const ImDatabase = { async searchMessages(appKey: string, params: MessageSearchParams): Promise { const db = getDb() const conditions: any[] = [ - Q.where('app_id', appKey), + Q.where('app_key', appKey), ] if (params.toId) { @@ -271,7 +271,7 @@ export const ImDatabase = { const query = db .get('im_conversations') .query( - Q.where('app_id', appKey), + Q.where('app_key', appKey), Q.sortBy('is_pinned', Q.desc), Q.sortBy('last_msg_time', Q.desc), ) @@ -284,7 +284,7 @@ export const ImDatabase = { const db = getDb() const convs = await db .get('im_conversations') - .query(Q.where('app_id', appKey), Q.where('target_id', targetId)) + .query(Q.where('app_key', appKey), Q.where('target_id', targetId)) .fetch() if (convs.length > 0) { await db.write(async () => { @@ -297,7 +297,7 @@ export const ImDatabase = { const db = getDb() const convs = await db .get('im_conversations') - .query(Q.where('app_id', appKey), Q.where('target_id', targetId)) + .query(Q.where('app_key', appKey), Q.where('target_id', targetId)) .fetch() if (convs.length > 0) { await db.write(async () => { @@ -314,7 +314,7 @@ export const ImDatabase = { const db = getDb() const convs = await db .get('im_conversations') - .query(Q.where('app_id', appKey), Q.where('target_id', targetId)) + .query(Q.where('app_key', appKey), Q.where('target_id', targetId)) .fetch() if (convs.length === 0) return null return convs[0].draft @@ -325,7 +325,7 @@ export const ImDatabase = { const convId = conversationId(appKey, currentUserId, targetId, chatType) const convs = await db .get('im_conversations') - .query(Q.where('app_id', appKey), Q.where('target_id', targetId)) + .query(Q.where('app_key', appKey), Q.where('target_id', targetId)) .fetch() const messages = await db .get('im_messages') diff --git a/packages/im/src/db/MessageModel.ts b/packages/im/src/db/MessageModel.ts index 13c4ddb..48697f8 100644 --- a/packages/im/src/db/MessageModel.ts +++ b/packages/im/src/db/MessageModel.ts @@ -5,7 +5,7 @@ export class MessageModel extends Model { static table = 'im_messages' @field('server_id') serverId!: string - @field('app_id') appKey!: string + @field('app_key') appKey!: string @field('conversation_id') conversationId!: string @field('from_user_id') fromUserId!: string @field('to_id') toId!: string diff --git a/packages/im/src/db/schema.ts b/packages/im/src/db/schema.ts index b801077..43687cf 100644 --- a/packages/im/src/db/schema.ts +++ b/packages/im/src/db/schema.ts @@ -6,7 +6,7 @@ export const imDbSchema = appSchema({ tableSchema({ name: 'im_conversations', columns: [ - { name: 'app_id', type: 'string', isIndexed: true }, + { name: 'app_key', type: 'string', isIndexed: true }, { name: 'target_id', type: 'string', isIndexed: true }, { name: 'chat_type', type: 'string' }, { name: 'last_msg_id', type: 'string', isOptional: true }, @@ -24,7 +24,7 @@ export const imDbSchema = appSchema({ name: 'im_messages', columns: [ { name: 'server_id', type: 'string', isIndexed: true }, - { name: 'app_id', type: 'string', isIndexed: true }, + { name: 'app_key', type: 'string', isIndexed: true }, { name: 'conversation_id', type: 'string', isIndexed: true }, { name: 'from_user_id', type: 'string' }, { name: 'to_id', type: 'string' },