Fix showing Search navigation tab from Agent pages on web client

The `has_documents' flag wasn't being passed. So the search tab
always showing up as empty instead of being dynamically enabled if
documents had been indexed.
This commit is contained in:
Debanjum Singh Solanky 2024-04-07 12:38:00 +05:30
parent 76cb543347
commit 8159d1ab25

View file

@ -135,6 +135,7 @@ def login_page(request: Request):
def agents_page(request: Request):
user: KhojUser = request.user.object if request.user.is_authenticated else None
user_picture = request.session.get("user", {}).get("picture") if user else None
has_documents = EntryAdapters.user_has_entries(user=user)
agents = AgentAdapters.get_all_accessible_agents(user)
agents_packet = list()
for agent in agents:
@ -156,7 +157,7 @@ def agents_page(request: Request):
"agents": agents_packet,
"khoj_version": state.khoj_version,
"username": user.username if user else None,
"has_documents": False,
"has_documents": has_documents,
"is_active": has_required_scope(request, ["premium"]),
"user_photo": user_picture,
},
@ -169,6 +170,7 @@ def agent_page(request: Request, agent_slug: str):
user_picture = request.session.get("user", {}).get("picture") if user else None
agent = AgentAdapters.get_agent_by_slug(agent_slug)
has_documents = EntryAdapters.user_has_entries(user=user)
if agent == None:
return templates.TemplateResponse(
@ -202,7 +204,7 @@ def agent_page(request: Request, agent_slug: str):
"agent": agent_metadata,
"khoj_version": state.khoj_version,
"username": user.username if user else None,
"has_documents": False,
"has_documents": has_documents,
"is_active": has_required_scope(request, ["premium"]),
"user_photo": user_picture,
},