diff --git a/app/DataBase/msg.py b/app/DataBase/msg.py index 1b03ce76..915efa7b 100644 --- a/app/DataBase/msg.py +++ b/app/DataBase/msg.py @@ -87,6 +87,24 @@ def get_messages_all(self): result.sort(key=lambda x: x[5]) return result + def get_messages_length(self): + sql = ''' + select count(*) + from MSG + ''' + if not self.open_flag: + return None + try: + lock.acquire(True) + self.cursor.execute(sql) + result = self.cursor.fetchone() + except Exception as e: + result = None + finally: + lock.release() + return result[0] + + def get_message_by_num(self, username_, local_id): sql = ''' select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime diff --git a/app/components/bubble_message.py b/app/components/bubble_message.py index 6a52cdf6..6dc3e75e 100644 --- a/app/components/bubble_message.py +++ b/app/components/bubble_message.py @@ -17,6 +17,8 @@ class TextMessage(QLabel): heightSingal = pyqtSignal(int) def __init__(self, text, is_send=False, parent=None): + if isinstance(text, bytes): + text = text.decode('utf-8') super(TextMessage, self).__init__(text, parent) font = QFont('微软雅黑', 12) self.setFont(font) diff --git a/app/ui_pc/chat/chat_info.py b/app/ui_pc/chat/chat_info.py index 9e8e36a3..5464be6a 100644 --- a/app/ui_pc/chat/chat_info.py +++ b/app/ui_pc/chat/chat_info.py @@ -142,7 +142,7 @@ class ShowChatThread(QThread): # heightSingal = pyqtSignal(int) def __init__(self, contact): super().__init__() - self.last_message_id = 9999999 + self.last_message_id = msg_db.get_messages_length() or 9999999 self.wxid = contact.wxid def run(self) -> None: