Add fetch messages button
This commit adds a fetch messages option in the chat. If clicked it will re-fetch messages for that chat for 1 month. It's disabled in production since that's not something we want to go live with, but it's very helpful for dogfooding/debugging while message reliability has still some issues.
This commit is contained in:
parent
e6c8e141e2
commit
94159746ea
|
@ -8,6 +8,7 @@ import ../../../../../app_service/service/contacts/service as contact_service
|
|||
import ../../../../../app_service/service/chat/service as chat_service
|
||||
import ../../../../../app_service/service/community/service as community_service
|
||||
import ../../../../../app_service/service/message/service as message_service
|
||||
import ../../../../../app_service/service/mailservers/service as mailservers_service
|
||||
import ../../../../../app_service/service/wallet_account/service as wallet_account_service
|
||||
|
||||
import ../../../../core/signals/types
|
||||
|
@ -26,6 +27,7 @@ type
|
|||
isUsersListAvailable: bool #users list is not available for 1:1 chat
|
||||
nodeConfigurationService: node_configuration_service.Service
|
||||
settingsService: settings_service.Service
|
||||
mailserversService: mailservers_service.Service
|
||||
contactService: contact_service.Service
|
||||
chatService: chat_service.Service
|
||||
communityService: community_service.Service
|
||||
|
@ -221,6 +223,9 @@ proc unblockChat*(self: Controller) =
|
|||
proc markAllMessagesRead*(self: Controller) =
|
||||
self.messageService.markAllMessagesRead(self.chatId)
|
||||
|
||||
proc requestMoreMessages*(self: Controller) =
|
||||
self.mailserversService.requestMoreMessages(self.chatId)
|
||||
|
||||
proc markMessageRead*(self: Controller, msgID: string) =
|
||||
self.messageService.markCertainMessagesRead(self.chatId, @[msgID])
|
||||
|
||||
|
|
|
@ -101,6 +101,9 @@ method unblockChat*(self: AccessInterface) {.base.} =
|
|||
method markAllMessagesRead*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method requestMoreMessages*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method markMessageRead*(self: AccessInterface, msgID: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -126,9 +126,6 @@ method editMessage*(self: AccessInterface, messageId: string, contentType: int,
|
|||
method onHistoryCleared*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method requestMoreMessages*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method fillGaps*(self: AccessInterface, messageId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
@ -159,6 +156,9 @@ method resetAndScrollToNewMessagesMarker*(self: AccessInterface) {.base.} =
|
|||
method markAllMessagesRead*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method requestMoreMessages*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method markMessagesAsRead*(self: AccessInterface, messages: seq[string]) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -281,6 +281,9 @@ method unblockChat*(self: Module) =
|
|||
method markAllMessagesRead*(self: Module) =
|
||||
self.controller.markAllMessagesRead()
|
||||
|
||||
method requestMoreMessages*(self: Module) =
|
||||
self.controller.requestMoreMessages()
|
||||
|
||||
method markMessageRead*(self: Module, msgID: string) =
|
||||
self.controller.markMessageRead(msgID)
|
||||
|
||||
|
|
|
@ -91,6 +91,9 @@ QtObject:
|
|||
proc markAllMessagesRead*(self: View) {.slot.} =
|
||||
self.delegate.markAllMessagesRead()
|
||||
|
||||
proc requestMoreMessages*(self: View) {.slot.} =
|
||||
self.delegate.requestMoreMessages()
|
||||
|
||||
proc markMessageRead*(self: View, msgID: string) {.slot.} =
|
||||
self.delegate.markMessageRead(msgID)
|
||||
|
||||
|
|
|
@ -479,6 +479,9 @@ proc unmuteChat*(self: Controller, chatId: string) =
|
|||
proc markAllMessagesRead*(self: Controller, chatId: string) =
|
||||
self.messageService.markAllMessagesRead(chatId)
|
||||
|
||||
proc requestMoreMessages*(self: Controller, chatId: string) =
|
||||
self.mailserversService.requestMoreMessages(chatId)
|
||||
|
||||
proc clearChatHistory*(self: Controller, chatId: string) =
|
||||
self.chatService.clearChatHistory(chatId)
|
||||
|
||||
|
|
|
@ -202,6 +202,9 @@ method markAllMessagesRead*(self: AccessInterface, chatId: string) {.base.} =
|
|||
method clearChatHistory*(self: AccessInterface, chatId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method requestMoreMessages*(self: AccessInterface, chatId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getCurrentFleet*(self: AccessInterface): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -902,6 +902,9 @@ method onMarkAllMessagesRead*(self: Module, chat: ChatDto) =
|
|||
method markAllMessagesRead*(self: Module, chatId: string) =
|
||||
self.controller.markAllMessagesRead(chatId)
|
||||
|
||||
method requestMoreMessages*(self: Module, chatId: string) =
|
||||
self.controller.requestMoreMessages(chatId)
|
||||
|
||||
method clearChatHistory*(self: Module, chatId: string) =
|
||||
self.controller.clearChatHistory(chatId)
|
||||
|
||||
|
|
|
@ -201,6 +201,9 @@ QtObject:
|
|||
proc markAllMessagesRead*(self: View, chatId: string) {.slot.} =
|
||||
self.delegate.markAllMessagesRead(chatId)
|
||||
|
||||
proc requestMoreMessages*(self: View, chatId: string) {.slot.} =
|
||||
self.delegate.requestMoreMessages(chatId)
|
||||
|
||||
proc clearChatHistory*(self: View, chatId: string) {.slot.} =
|
||||
self.delegate.clearChatHistory(chatId)
|
||||
|
||||
|
|
|
@ -49,23 +49,20 @@ const requestMoreMessagesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall
|
|||
let arg = decode[RequestMoreMessagesTaskArg](argEncoded)
|
||||
try:
|
||||
info "Requesting additional message history for chat", chatId=arg.chatId
|
||||
let response = status_mailservers.syncChatFromSyncedFrom(arg.chatId)
|
||||
let response = status_mailservers.requestMoreMessages(arg.chatId)
|
||||
|
||||
if(not response.error.isNil):
|
||||
error "Could not request additional messages due to error", errDescription = response.error.message
|
||||
|
||||
let syncedFrom = response.result.getInt()
|
||||
if(syncedFrom != 0):
|
||||
let resultJson = %* {
|
||||
"chatId": arg.chatId,
|
||||
"syncedFrom": syncedFrom
|
||||
}
|
||||
arg.finish(%resultJson)
|
||||
arg.finish(%*{"error": response.error.message})
|
||||
else:
|
||||
warn "Syncing mailserver failed", errDescription=arg.chatId
|
||||
info "synced mailserver successfully", chatID=arg.chatId
|
||||
arg.finish(%*{"error": ""})
|
||||
|
||||
except Exception as e:
|
||||
warn "Could not request additional messages due to error", errDescription=e.msg
|
||||
arg.finish(%* {
|
||||
"error": e.msg
|
||||
})
|
||||
|
||||
const fillGapsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let arg = decode[FillGapsTaskArg](argEncoded)
|
||||
|
@ -126,20 +123,11 @@ QtObject:
|
|||
if MAILSERVER_ID != "":
|
||||
discard self.settingsService.pinMailserver(MAILSERVER_ID, fleet)
|
||||
|
||||
proc mailserverSynced*(self: Service, syncInfo: string) {.slot.} =
|
||||
let syncInfoParsed = parseJson(syncInfo)
|
||||
let signalData = MailserverSyncedArgs(
|
||||
chatId: syncInfoParsed["chatId"].getStr(),
|
||||
syncedFrom: syncInfoParsed["syncedFrom"].getInt()
|
||||
)
|
||||
self.events.emit(SIGNAL_MAILSERVER_SYNCED, signalData)
|
||||
|
||||
proc requestMoreMessages*(self: Service, chatId: string) =
|
||||
let arg = RequestMoreMessagesTaskArg(
|
||||
tptr: cast[ByteAddress](requestMoreMessagesTask),
|
||||
vptr: cast[ByteAddress](self.vptr),
|
||||
chatId: chatId,
|
||||
slot: "mailserverSynced"
|
||||
)
|
||||
self.threadpool.start(arg)
|
||||
|
||||
|
|
|
@ -32,4 +32,11 @@ proc fillGaps*(chatId: string, messageIds: seq[string]): RpcResponse[JsonNode] {
|
|||
|
||||
proc requestAllHistoricMessagesWithRetries*(forceFetchingBackup: bool): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %*[forceFetchingBackup]
|
||||
result = core.callPrivateRPC("requestAllHistoricMessagesWithRetries".prefix, payload)
|
||||
result = core.callPrivateRPC("requestAllHistoricMessagesWithRetries".prefix, payload)
|
||||
|
||||
proc requestMoreMessages*(chatId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %*[{
|
||||
"id": chatId
|
||||
}]
|
||||
result = core.callPrivateRPC("fetchMessages".prefix, payload)
|
||||
info "requestMoreMessages", topics="mailserver-interaction", rpc_method="wakuext_fetchMessages", chatId, result
|
||||
|
|
|
@ -232,7 +232,7 @@ Item {
|
|||
onAddRemoveGroupMember: {
|
||||
root.addRemoveGroupMember()
|
||||
}
|
||||
onFetchMoreMessages: {
|
||||
onRequestMoreMessages: {
|
||||
messageStore.requestMoreMessages();
|
||||
}
|
||||
onLeaveGroup: {
|
||||
|
|
|
@ -179,6 +179,10 @@ Item {
|
|||
root.chatSectionModule.markAllMessagesRead(chatId)
|
||||
}
|
||||
|
||||
onRequestMoreMessages: {
|
||||
root.chatSectionModule.requestMoreMessages(chatId)
|
||||
}
|
||||
|
||||
onClearChatHistory: {
|
||||
root.chatSectionModule.clearChatHistory(chatId)
|
||||
}
|
||||
|
|
|
@ -339,6 +339,10 @@ Item {
|
|||
root.communitySectionModule.markAllMessagesRead(chatId)
|
||||
}
|
||||
|
||||
onRequestMoreMessages: {
|
||||
root.communitySectionModule.requestMoreMessages(chatId)
|
||||
}
|
||||
|
||||
onClearChatHistory: {
|
||||
root.communitySectionModule.clearChatHistory(chatId)
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ StatusMenu {
|
|||
|
||||
signal createCommunityChannel(string chatId, string newName, string newDescription, string newEmoji, string newColor)
|
||||
signal editCommunityChannel(string chatId, string newName, string newDescription, string newEmoji, string newColor, string newCategory)
|
||||
signal fetchMoreMessages(int timeFrame)
|
||||
signal requestMoreMessages(string chatId)
|
||||
signal addRemoveGroupMember()
|
||||
|
||||
width: root.amIChatAdmin && (root.chatType === Constants.chatType.privateGroupChat) ? 207 : implicitWidth
|
||||
|
@ -124,39 +124,15 @@ StatusMenu {
|
|||
}
|
||||
}
|
||||
|
||||
//TODO uncomment when implemented
|
||||
// StatusMenu {
|
||||
// title: qsTr("Fetch messages")
|
||||
// enabled: (root.chatType === Constants.chatType.oneToOne ||
|
||||
// root.chatType === Constants.chatType.privateGroupChat)
|
||||
// StatusAction {
|
||||
// text: "Last 24 hours"
|
||||
// onTriggered: {
|
||||
// root.fetchMoreMessages();
|
||||
// }
|
||||
// }
|
||||
|
||||
// StatusAction {
|
||||
// text: "Last 2 days"
|
||||
// onTriggered: {
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// StatusAction {
|
||||
// text: "Last 3 days"
|
||||
// onTriggered: {
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// StatusAction {
|
||||
// text: "Last 7 days"
|
||||
// onTriggered: {
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
StatusAction {
|
||||
objectName: "chatFetchMessagesMenuItem"
|
||||
text: qsTr("Fetch messages")
|
||||
icon.name: "download"
|
||||
enabled: !production
|
||||
onTriggered: {
|
||||
root.requestMoreMessages(root.chatId)
|
||||
}
|
||||
}
|
||||
|
||||
StatusAction {
|
||||
objectName: "editChannelMenuItem"
|
||||
|
|
Loading…
Reference in New Issue