fix: code review
This commit is contained in:
parent
d0de5c074f
commit
366ebffbe7
|
@ -311,7 +311,7 @@ QtObject:
|
|||
self.messageList[channel] = newChatMessageList(channel, self.status, not chat.isNil and chat.chatType != ChatType.Profile)
|
||||
self.channelOpenTime[channel] = now().toTime.toUnix * 1000
|
||||
|
||||
proc messagePushed*(self: ChatsView) {.signal.}
|
||||
proc messagePushed*(self: ChatsView, messageIndex: int) {.signal.}
|
||||
proc newMessagePushed*(self: ChatsView) {.signal.}
|
||||
|
||||
proc messageNotificationPushed*(self: ChatsView, chatId: string, text: string, messageType: string, chatType: int, timestamp: string, identicon: string, username: string, hasMention: bool, isAddedContact: bool, channelName: string) {.signal.}
|
||||
|
@ -329,15 +329,18 @@ QtObject:
|
|||
for msg in messages.mitems:
|
||||
self.upsertChannel(msg.chatId)
|
||||
msg.userName = self.status.chat.getUserName(msg.fromAuthor, msg.alias)
|
||||
var msgIndex:int;
|
||||
if self.status.chat.channels.hasKey(msg.chatId):
|
||||
let chat = self.status.chat.channels[msg.chatId]
|
||||
if (chat.chatType == ChatType.Profile):
|
||||
let timelineChatId = status_utils.getTimelineChatId()
|
||||
self.messageList[timelineChatId].add(msg)
|
||||
if self.activeChannel.id == timelineChatId: self.activeChannelChanged()
|
||||
msgIndex = self.messageList[timelineChatId].messages.len - 1
|
||||
else:
|
||||
self.messageList[msg.chatId].add(msg)
|
||||
self.messagePushed()
|
||||
msgIndex = self.messageList[msg.chatId].messages.len - 1
|
||||
self.messagePushed(msgIndex)
|
||||
if self.channelOpenTime.getOrDefault(msg.chatId, high(int64)) < msg.timestamp.parseFloat.fromUnixFloat.toUnix:
|
||||
let channel = self.chats.getChannelById(msg.chatId)
|
||||
if (channel == nil):
|
||||
|
@ -399,7 +402,7 @@ QtObject:
|
|||
|
||||
proc pushChatItem*(self: ChatsView, chatItem: Chat) =
|
||||
discard self.chats.addChatItemToList(chatItem)
|
||||
self.messagePushed()
|
||||
self.messagePushed(self.messageList[chatItem.id].messages.len - 1)
|
||||
|
||||
proc setTimelineChat*(self: ChatsView, chatItem: Chat) =
|
||||
self.timelineChat = chatItem
|
||||
|
|
|
@ -41,12 +41,27 @@ StackLayout {
|
|||
|
||||
currentIndex: chatsModel.activeChannelIndex > -1 && chatGroupsListViewCount > 0 ? 0 : 1
|
||||
|
||||
|
||||
property var idMap: {}
|
||||
|
||||
function addSuggestionFromMessageList(i){
|
||||
const contactAddr = chatsModel.messageList.getMessageData(i, "publicKey");
|
||||
if(idMap[contactAddr]) return;
|
||||
chatInput.suggestionsList.append({
|
||||
alias: chatsModel.messageList.getMessageData(i, "alias"),
|
||||
ensName: chatsModel.messageList.getMessageData(i, "ensName"),
|
||||
address: contactAddr,
|
||||
identicon: chatsModel.messageList.getMessageData(i, "identicon"),
|
||||
localNickname: chatsModel.messageList.getMessageData(i, "localName")
|
||||
});
|
||||
idMap[contactAddr] = true;
|
||||
}
|
||||
|
||||
function populateSuggestions(){
|
||||
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
||||
chatInput.suggestionsList.clear()
|
||||
const len = chatsModel.suggestionList.rowCount()
|
||||
|
||||
var idMap = {}
|
||||
idMap = {}
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
const contactAddr = chatsModel.suggestionList.rowData(i, "address");
|
||||
|
@ -62,16 +77,7 @@ StackLayout {
|
|||
}
|
||||
const len2 = chatsModel.messageList.rowCount();
|
||||
for (let i = 0; i < len2; i++) {
|
||||
const contactAddr = chatsModel.messageList.getMessageData(i, "publicKey");
|
||||
if(idMap[contactAddr]) continue;
|
||||
chatInput.suggestionsList.append({
|
||||
alias: chatsModel.messageList.getMessageData(i, "alias"),
|
||||
ensName: chatsModel.messageList.getMessageData(i, "ensName"),
|
||||
address: contactAddr,
|
||||
identicon: chatsModel.messageList.getMessageData(i, "identicon"),
|
||||
localNickname: chatsModel.messageList.getMessageData(i, "localName")
|
||||
});
|
||||
idMap[contactAddr] = true;
|
||||
addSuggestionFromMessageList(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,10 +211,11 @@ StackLayout {
|
|||
target: chatsModel
|
||||
onActiveChannelChanged: {
|
||||
chatInput.suggestions.hide();
|
||||
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
||||
populateSuggestions();
|
||||
}
|
||||
onMessagePushed: {
|
||||
populateSuggestions();
|
||||
addSuggestionFromMessageList(messageIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue