diff --git a/CHANGELOG.md b/CHANGELOG.md
index 890dedce2fe1..bc72fcf0505d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,23 @@
# Changelog
+### [Version 1.36.36](https://github.com/lobehub/lobe-chat/compare/v1.36.35...v1.36.36)
+
+Released on **2024-12-19**
+
+
+
+
+Improvements and Fixes
+
+
+
+
+
+[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
+
+
+
### [Version 1.36.35](https://github.com/lobehub/lobe-chat/compare/v1.36.34...v1.36.35)
Released on **2024-12-18**
diff --git a/changelog/v1.json b/changelog/v1.json
index 37a88fad9547..55ae9614e35f 100644
--- a/changelog/v1.json
+++ b/changelog/v1.json
@@ -1,4 +1,9 @@
[
+ {
+ "children": {},
+ "date": "2024-12-19",
+ "version": "1.36.36"
+ },
{
"children": {
"improvements": ["Improve home page loading for better UX."]
diff --git a/package.json b/package.json
index 6a0ff07b59fc..f1456ffa7b88 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@lobehub/chat",
- "version": "1.36.35",
+ "version": "1.36.36",
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
"keywords": [
"framework",
diff --git a/src/database/server/models/message.ts b/src/database/server/models/message.ts
index 7fa7a477df22..543b71a742ce 100644
--- a/src/database/server/models/message.ts
+++ b/src/database/server/models/message.ts
@@ -294,6 +294,16 @@ export class MessageModel {
return result[0].count;
};
+ hasMoreThanN = async (n: number): Promise => {
+ const result = await this.db
+ .select({ id: messages.id })
+ .from(messages)
+ .where(eq(messages.userId, this.userId))
+ .limit(n + 1);
+
+ return result.length > n;
+ };
+
// **************** Create *************** //
create = async (
diff --git a/src/database/server/models/session.ts b/src/database/server/models/session.ts
index 74a4ae87dc39..2a39ba4127bd 100644
--- a/src/database/server/models/session.ts
+++ b/src/database/server/models/session.ts
@@ -95,6 +95,16 @@ export class SessionModel {
return result[0].count;
};
+ hasMoreThanN = async (n: number): Promise => {
+ const result = await this.db
+ .select({ id: sessions.id })
+ .from(sessions)
+ .where(eq(sessions.userId, this.userId))
+ .limit(n + 1);
+
+ return result.length > n;
+ };
+
// **************** Create *************** //
create = async ({
diff --git a/src/server/routers/lambda/user.ts b/src/server/routers/lambda/user.ts
index f7522004940b..6c8f6a19a794 100644
--- a/src/server/routers/lambda/user.ts
+++ b/src/server/routers/lambda/user.ts
@@ -58,16 +58,17 @@ export const userRouter = router({
}
const messageModel = new MessageModel(serverDB, ctx.userId);
- const messageCount = await messageModel.count();
+ const hasMoreThan4Messages = await messageModel.hasMoreThanN(4);
const sessionModel = new SessionModel(serverDB, ctx.userId);
- const sessionCount = await sessionModel.count();
+ const hasAnyMessages = await messageModel.hasMoreThanN(0);
+ const hasExtraSession = await sessionModel.hasMoreThanN(1);
return {
- canEnablePWAGuide: messageCount >= 4,
- canEnableTrace: messageCount >= 4,
+ canEnablePWAGuide: hasMoreThan4Messages,
+ canEnableTrace: hasMoreThan4Messages,
// 有消息,或者创建过助手,则认为有 conversation
- hasConversation: messageCount > 0 || sessionCount > 1,
+ hasConversation: hasAnyMessages || hasExtraSession,
// always return true for community version
isOnboard: state.isOnboarded || true,