Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

读取消息记录数 #95

Merged
merged 5 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/DataBase/msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/components/bubble_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/ui_pc/chat/chat_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down