mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
修复提交疏漏
修改在查询群历史消息时,如未提供msg_seq,则返回最新消息
This commit is contained in:
@@ -61,6 +61,10 @@ class LimitedHashTable<K, V> {
|
||||
this.valueToKey.delete(value);
|
||||
}
|
||||
}
|
||||
|
||||
getKeyList(): K[] {
|
||||
return Array.from(this.keyToValue.keys());
|
||||
}
|
||||
}
|
||||
|
||||
class MessageUniqueWrapper {
|
||||
@@ -111,6 +115,25 @@ class MessageUniqueWrapper {
|
||||
this.msgIdMap.resize(maxSize);
|
||||
this.msgDataMap.resize(maxSize);
|
||||
}
|
||||
getNthLatestShortIdByPeer(peer: Peer, index: number = 1): number | undefined {
|
||||
const peerUid = peer.peerUid;
|
||||
const chatType = peer.chatType;
|
||||
const keys = this.msgDataMap.getKeyList();
|
||||
const matches: number[] = [];
|
||||
for (const key of keys) {
|
||||
const [msgId, chatTypeStr, peerUidStr] = key.split('|');
|
||||
if (peerUidStr === peerUid && chatTypeStr === chatType.toString()) {
|
||||
const shortId = this.msgDataMap.getValue(key);
|
||||
if (shortId) {
|
||||
matches.push(shortId);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (matches.length >= index) {
|
||||
return matches[matches.length - index];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export const MessageUnique: MessageUniqueWrapper = new MessageUniqueWrapper();
|
||||
Reference in New Issue
Block a user