This commit is contained in:
Timothy Jaeryang Baek
2026-07-26 23:49:03 -04:00
parent 2196b4e1ff
commit 6f93ecd4fd
16 changed files with 550 additions and 62 deletions
+11 -7
View File
@@ -545,20 +545,24 @@ async def chat_events(sid, data):
event_type = event_data.get('type')
if event_type == 'last_read_at':
last_read_at = await Chats.update_chat_last_read_at_by_id(data['chat_id'], user['id'])
if not last_read_at:
read_update = await Chats.update_chat_last_read_at_by_id(data['chat_id'], user['id'])
if not read_update:
return
last_read_at, was_unread = read_update
response_data = {
'chat_id': data['chat_id'],
'last_read_at': last_read_at,
}
if was_unread:
response_data['folder_unread_counts'] = await get_folder_unread_counts(user['id'])
await sio.emit(
'events',
{
'chat_id': data['chat_id'],
'data': {
'type': 'chat:list',
'data': {
'chat_id': data['chat_id'],
'last_read_at': last_read_at,
'folder_unread_counts': await get_folder_unread_counts(user['id']),
},
'data': response_data,
},
},
room=f'user:{user["id"]}',