Skip to content

Commit

Permalink
Don't list empty conversations
Browse files Browse the repository at this point in the history
  • Loading branch information
smathot committed Apr 17, 2024
1 parent 94a8c5e commit 8f7fc02
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions heymans/database/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,16 @@ def update_active_conversation(self, conversation_data: dict) -> bool:
def list_conversations(self) -> dict:

conversations = {}
user = User.query.filter_by(user_id=self.user_id).one()
for conversation in \
Conversation.query.filter_by(user_id=self.user_id).all():
try:
data = json.loads(self.encryption_manager.decrypt_data(
conversation.data))
# Don't list empty conversations except for the active one
if len(data.get('message_history', [])) < 2 and \
user.active_conversation_id != conversation.conversation_id:
continue
conversations[conversation.conversation_id] = (
data.get('title', 'Untitled conversation'),
data.get('last_updated', time.time()))
Expand Down

0 comments on commit 8f7fc02

Please sign in to comment.