fix: display loading indicator depending on mailserver request status

This commit is contained in:
Richard Ramos 2022-01-19 11:44:07 -04:00
parent 8d27d784c1
commit d713c6fe9f
5 changed files with 7 additions and 27 deletions

View File

@ -58,7 +58,6 @@ proc handleChatEvents(self: ChatController) =
# app to be slower
self.status.events.on("chatUpdate") do(e: Args):
var evArgs = ChatUpdateArgs(e)
self.view.hideLoadingIndicator()
self.view.updateChats(evArgs.chats)
self.view.pushMessages(evArgs.messages)
self.view.pushMembers(evArgs.chats)

View File

@ -22,15 +22,14 @@ proc handleSignals(self: ChatController) =
var data = CommunitySignal(e)
self.view.communities.addCommunityToList(data.community)
self.status.events.on(SignalType.MailserverRequestCompleted.event) do(e:Args):
# TODO: if the signal contains a cursor, request additional messages
# else:
self.view.hideLoadingIndicator()
self.status.events.on(SignalType.HistoryRequestStarted.event) do(e:Args):
self.view.messageView.setLoadingMessages(true)
self.status.events.on(SignalType.MailserverRequestExpired.event) do(e:Args):
# TODO: retry mailserver request up to N times or change mailserver
# If > N, then
self.view.hideLoadingIndicator()
self.status.events.on(SignalType.HistoryRequestCompleted.event) do(e:Args):
self.view.messageView.setLoadingMessages(false)
self.status.events.on(SignalType.HistoryRequestFailed.event) do(e:Args):
self.view.messageView.setLoadingMessages(false)
let mailserverWorker = self.appService.marathon[MailserverWorker().name]
self.status.events.on(SignalType.MailserverAvailable.event) do(e:Args):

View File

@ -451,8 +451,6 @@ QtObject:
proc pushPinnedMessages*(self: ChatsView, pinnedMessages: var seq[Message]) =
self.messageView.pushPinnedMessages(pinnedMessages)
proc hideLoadingIndicator*(self: ChatsView) {.slot.} =
self.messageView.hideLoadingIndicator()
proc deleteMessage*(self: ChatsView, channelId: string, messageId: string): bool =
result = self.messageView.deleteMessage(channelId, messageId)

View File

@ -307,18 +307,6 @@ Item {
height: chatInput.height
Layout.preferredHeight: height
Connections {
target: root.rootStore.chatsModelInst.messageView
onLoadingMessagesChanged:
if(value){
loadingMessagesIndicator.active = true
} else {
timer.setTimeout(function(){
loadingMessagesIndicator.active = false;
}, 5000);
}
}
Loader {
id: loadingMessagesIndicator
active: root.rootStore.chatsModelInst.messageView.loadingMessages
@ -538,7 +526,6 @@ Item {
Connections {
target: root.rootStore.chatsModelInst.channelView
onActiveChannelChanged: {
root.rootStore.chatsModelInst.messageView.hideLoadingIndicator()
SelectedMessage.reset();
chatColumn.isReply = false;
}

View File

@ -260,9 +260,6 @@ Column {
Component {
id: fetchMoreMessagesButtonComponent
FetchMoreMessagesButton {
onClicked: {
root.chatsModel.messageView.hideLoadingIndicator();
}
onTimerTriggered: {
root.chatsModel.requestMoreMessages(Constants.fetchRangeLast24Hours);
}