fix(@desktop): windows application unresponsive when fetching Status updates

This commit is contained in:
Andrei Smirnov 2021-07-14 13:10:08 +03:00 committed by Iuri Matias
parent 511c959121
commit cd423336e1
4 changed files with 25 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import ../../../status/utils as status_utils
import ../../../status/chat/[chat, message]
import ../../../status/profile/profile
import ../../../status/tasks/[qt, task_runner_impl]
import ../../../status/tasks/marathon/mailserver/worker
import communities, chat_item, channels_list, communities, community_list, message_list, channel, message_item
@ -375,9 +376,10 @@ QtObject:
notify = loadingMessagesChanged
proc fillGaps*(self: MessageView, messageId: string) {.slot.} =
self.loadingMessages = true
self.loadingMessagesChanged(true)
discard self.status.mailservers.fillGaps(self.channelView.activeChannel.id, @[messageId])
self.setLoadingMessages(true)
let mailserverWorker = self.status.tasks.marathon[MailserverWorker().name]
let task = FillGapsTaskArg( `method`: "fillGaps", chatId: self.channelView.activeChannel.id, messageIds: @[messageId])
mailserverWorker.start(task)
proc unreadMessages*(self: MessageView): int {.slot.} =
result = self.unreadMessageCnt

View File

@ -150,6 +150,10 @@ proc requestMoreMessages*(self: MailserverModel, chatId: string) =
debug "Requesting more messages from", mailserver=self.activeMailserver, chatId=chatId
discard status_mailservers.syncChatFromSyncedFrom(chatId)
proc fillGaps*(self: MailserverModel, chatId: string, messageIds: seq[string]) =
debug "Requesting fill gaps from", mailserver=self.activeMailserver, chatId=chatId
discard status_mailservers.fillGaps(chatId, messageIds)
proc findNewMailserver(self: MailserverModel) =
warn "Finding a new mailserver..."

View File

@ -23,6 +23,9 @@ type
GetActiveMailserverTaskArg* = ref object of MarathonTaskArg
RequestMessagesTaskArg* = ref object of MarathonTaskArg
chatId*: string
FillGapsTaskArg* = ref object of MarathonTaskArg
chatId*: string
messageIds*: seq[string]
AddMailserverTopicTaskArg* = ref object of MarathonTaskArg
PeerSummaryChangeTaskArg* = ref object of MarathonTaskArg
peers*: seq[string]
@ -97,6 +100,10 @@ proc processMessage(mailserverModel: MailserverModel, received: string) =
let taskArg = decode[RequestMessagesTaskArg](received)
mailserverModel.requestMoreMessages(taskArg.chatId)
of "fillGaps":
let taskArg = decode[FillGapsTaskArg](received)
mailserverModel.fillGaps(taskArg.chatId, taskArg.messageIds)
of "getActiveMailserver":
let
taskArg = decode[GetActiveMailserverTaskArg](received)

View File

@ -164,5 +164,14 @@ ScrollView {
timeout: model.timeout
}
}
Loader {
active: chatsModel.messageView.loadingMessages
sourceComponent: LoadingAnimation {}
anchors.right: timelineContainer.right
anchors.top: statusUpdateInput.bottom
anchors.rightMargin: Style.current.padding
anchors.topMargin: Style.current.padding
}
}
}