Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

fix: if db is empty, will never show new convos until refresh

Daniel Avila626a8fbd8e04
diff --git a/api/models/Conversation.js b/api/models/Conversation.js
index 622744d27a..c4151198cd 100644
--- a/api/models/Conversation.js
+++ b/api/models/Conversation.js
@@ -93,7 +93,7 @@ module.exports = {
// getConvos: async () => await Conversation.find({}).sort({ createdAt: -1 }).exec(),
getConvosByPage: async (pageNumber = 1, pageSize = 12) => {
try {
- const totalConvos = await Conversation.countDocuments();
+ const totalConvos = (await Conversation.countDocuments()) || 1;
const totalPages = Math.ceil(totalConvos / pageSize);
const convos = await Conversation.find()
.sort({ createdAt: -1, created: -1 })