feat: allow for fetching messages older than 24 hours
This commit is contained in:
parent
5b8e3156aa
commit
8bf82e1dd6
|
@ -487,12 +487,12 @@ QtObject:
|
|||
read = isLoadingMessages
|
||||
notify = loadingMessagesChanged
|
||||
|
||||
proc requestMoreMessages*(self: ChatsView) {.slot.} =
|
||||
proc requestMoreMessages*(self: ChatsView, fetchRange: int) {.slot.} =
|
||||
self.loadingMessages = true
|
||||
self.loadingMessagesChanged()
|
||||
let topics = self.status.mailservers.getMailserverTopicsByChatId(self.activeChannel.id).map(topic => topic.topic)
|
||||
let currentOldestMessageTimestamp = self.oldestMessageTimestamp
|
||||
self.oldestMessageTimestamp = self.oldestMessageTimestamp - 86400
|
||||
self.oldestMessageTimestamp = self.oldestMessageTimestamp - fetchRange
|
||||
|
||||
self.status.mailservers.requestMessages(topics, self.oldestMessageTimestamp, currentOldestMessageTimestamp, true)
|
||||
self.oldestMessageTimestampChanged()
|
||||
|
|
|
@ -130,7 +130,7 @@ Item {
|
|||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
chatsModel.requestMoreMessages()
|
||||
chatsModel.requestMoreMessages(Constants.fetchRangeLast24Hours)
|
||||
timer.setTimeout(function(){
|
||||
chatsModel.hideLoadingIndicator()
|
||||
}, 3000);
|
||||
|
|
|
@ -16,6 +16,11 @@ ScrollView {
|
|||
contentHeight: channelListContent.height + Style.current.padding
|
||||
clip: true
|
||||
|
||||
Timer {
|
||||
id: timer
|
||||
}
|
||||
|
||||
|
||||
Item {
|
||||
id: channelListContent
|
||||
Layout.fillHeight: true
|
||||
|
@ -198,13 +203,49 @@ ScrollView {
|
|||
|
||||
// TODO call fetch for the wanted duration
|
||||
//% "Last 24 hours"
|
||||
Action { text: qsTrId("last-24-hours"); icon.width: 0; }
|
||||
Action {
|
||||
text: qsTrId("last-24-hours");
|
||||
icon.width: 0;
|
||||
onTriggered: {
|
||||
chatsModel.requestMoreMessages(Constants.fetchRangeLast24Hours)
|
||||
timer.setTimeout(function(){
|
||||
chatsModel.hideLoadingIndicator()
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
//% "Last 2 days"
|
||||
Action { text: qsTrId("last-2-days"); icon.width: 0; }
|
||||
Action {
|
||||
text: qsTrId("last-2-days");
|
||||
icon.width: 0;
|
||||
onTriggered: {
|
||||
chatsModel.requestMoreMessages(Constants.fetchRangeLast2Days)
|
||||
timer.setTimeout(function(){
|
||||
chatsModel.hideLoadingIndicator()
|
||||
}, 4000);
|
||||
}
|
||||
}
|
||||
//% "Last 3 days"
|
||||
Action { text: qsTrId("last-3-days"); icon.width: 0; }
|
||||
Action {
|
||||
text: qsTrId("last-3-days");
|
||||
icon.width: 0;
|
||||
onTriggered: {
|
||||
chatsModel.requestMoreMessages(Constants.fetchRangeLast3Days)
|
||||
timer.setTimeout(function(){
|
||||
chatsModel.hideLoadingIndicator()
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
//% "Last 7 days"
|
||||
Action { text: qsTrId("last-7-days"); icon.width: 0; }
|
||||
Action {
|
||||
text: qsTrId("last-7-days");
|
||||
icon.width: 0;
|
||||
onTriggered: {
|
||||
chatsModel.requestMoreMessages(Constants.fetchRangeLast7Days)
|
||||
timer.setTimeout(function(){
|
||||
chatsModel.hideLoadingIndicator()
|
||||
}, 7000);
|
||||
}
|
||||
}
|
||||
}
|
||||
Action {
|
||||
//% "Clear History"
|
||||
|
|
|
@ -7,6 +7,11 @@ QtObject {
|
|||
readonly property int chatTypePublic: 2
|
||||
readonly property int chatTypePrivateGroupChat: 3
|
||||
|
||||
readonly property int fetchRangeLast24Hours: 86400
|
||||
readonly property int fetchRangeLast2Days: 172800
|
||||
readonly property int fetchRangeLast3Days: 259200
|
||||
readonly property int fetchRangeLast7Days: 604800
|
||||
|
||||
readonly property int limitLongChatText: 500
|
||||
readonly property int limitLongChatTextCompactMode: 1000
|
||||
|
||||
|
|
Loading…
Reference in New Issue