Add contact's status if present (Android)

This commit is contained in:
KnugiHK
2023-06-20 14:07:42 +08:00
parent 55bc62cdc1
commit 136152dc18
4 changed files with 22 additions and 7 deletions

View File

@@ -22,6 +22,7 @@ class ChatStore():
self.my_avatar = None
self.their_avatar = None
self.their_avatar_thumb = None
self.status = None
def add_message(self, id, message):
if not isinstance(message, Message):
@@ -40,6 +41,7 @@ class ChatStore():
'my_avatar': self.my_avatar,
'their_avatar': self.their_avatar,
'their_avatar_thumb': self.their_avatar_thumb,
'status': self.status,
'messages': serialized_msgs
}

View File

@@ -155,10 +155,12 @@ def contacts(db, data):
total_row_number = c.fetchone()[0]
print(f"Processing contacts...({total_row_number})")
c.execute("""SELECT jid, COALESCE(display_name, wa_name) as display_name FROM wa_contacts; """)
c.execute("""SELECT jid, COALESCE(display_name, wa_name) as display_name, status FROM wa_contacts; """)
row = c.fetchone()
while row is not None:
data[row["jid"]] = ChatStore(Device.ANDROID, row["display_name"])
if row["status"] is not None:
data[row["jid"]].status = row["status"]
row = c.fetchone()
@@ -702,7 +704,8 @@ def create_html(
f"{safe_file_name}-{current_page + 1}.html",
chat.my_avatar,
chat.their_avatar,
chat.their_avatar_thumb
chat.their_avatar_thumb,
chat.status
)
render_box = [message]
current_size = 0
@@ -723,7 +726,8 @@ def create_html(
False,
chat.my_avatar,
chat.their_avatar,
chat.their_avatar_thumb
chat.their_avatar_thumb,
chat.status
)
else:
render_box.append(message)
@@ -739,7 +743,8 @@ def create_html(
False,
chat.my_avatar,
chat.their_avatar,
chat.their_avatar_thumb
chat.their_avatar_thumb,
chat.status
)
if current % 10 == 0:
print(f"Generating chats...({current}/{total_row_number})", end="\r")

View File

@@ -71,7 +71,8 @@ def rendering(
next,
my_avatar,
their_avatar,
their_avatar_thumb
their_avatar_thumb,
status
):
if their_avatar_thumb is None and their_avatar is not None:
their_avatar_thumb = their_avatar
@@ -84,7 +85,8 @@ def rendering(
their_avatar=their_avatar,
their_avatar_thumb=their_avatar_thumb,
w3css=w3css,
next=next
next=next,
status=status,
)
)

View File

@@ -89,7 +89,13 @@
</style>
</head>
<body>
<header class="w3-center w3-top">Chat history with {{ name }}</header>
<header class="w3-center w3-top">
Chat history with {{ name }}
{% if status is not none %}
<br>
<span class="w3-small">{{ status }}</span>
{% endif %}
</header>
<article class="w3-container">
<div class="table">
{% set last = {'last': 946688461.001} %}