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
|
read = isLoadingMessages
|
||||||
notify = loadingMessagesChanged
|
notify = loadingMessagesChanged
|
||||||
|
|
||||||
proc requestMoreMessages*(self: ChatsView) {.slot.} =
|
proc requestMoreMessages*(self: ChatsView, fetchRange: int) {.slot.} =
|
||||||
self.loadingMessages = true
|
self.loadingMessages = true
|
||||||
self.loadingMessagesChanged()
|
self.loadingMessagesChanged()
|
||||||
let topics = self.status.mailservers.getMailserverTopicsByChatId(self.activeChannel.id).map(topic => topic.topic)
|
let topics = self.status.mailservers.getMailserverTopicsByChatId(self.activeChannel.id).map(topic => topic.topic)
|
||||||
let currentOldestMessageTimestamp = self.oldestMessageTimestamp
|
let currentOldestMessageTimestamp = self.oldestMessageTimestamp
|
||||||
self.oldestMessageTimestamp = self.oldestMessageTimestamp - 86400
|
self.oldestMessageTimestamp = self.oldestMessageTimestamp - fetchRange
|
||||||
|
|
||||||
self.status.mailservers.requestMessages(topics, self.oldestMessageTimestamp, currentOldestMessageTimestamp, true)
|
self.status.mailservers.requestMessages(topics, self.oldestMessageTimestamp, currentOldestMessageTimestamp, true)
|
||||||
self.oldestMessageTimestampChanged()
|
self.oldestMessageTimestampChanged()
|
||||||
|
|
|
@ -130,7 +130,7 @@ Item {
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
chatsModel.requestMoreMessages()
|
chatsModel.requestMoreMessages(Constants.fetchRangeLast24Hours)
|
||||||
timer.setTimeout(function(){
|
timer.setTimeout(function(){
|
||||||
chatsModel.hideLoadingIndicator()
|
chatsModel.hideLoadingIndicator()
|
||||||
}, 3000);
|
}, 3000);
|
||||||
|
|
|
@ -16,6 +16,11 @@ ScrollView {
|
||||||
contentHeight: channelListContent.height + Style.current.padding
|
contentHeight: channelListContent.height + Style.current.padding
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: timer
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: channelListContent
|
id: channelListContent
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
@ -198,13 +203,49 @@ ScrollView {
|
||||||
|
|
||||||
// TODO call fetch for the wanted duration
|
// TODO call fetch for the wanted duration
|
||||||
//% "Last 24 hours"
|
//% "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"
|
//% "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"
|
//% "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"
|
//% "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 {
|
Action {
|
||||||
//% "Clear History"
|
//% "Clear History"
|
||||||
|
|
|
@ -7,6 +7,11 @@ QtObject {
|
||||||
readonly property int chatTypePublic: 2
|
readonly property int chatTypePublic: 2
|
||||||
readonly property int chatTypePrivateGroupChat: 3
|
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 limitLongChatText: 500
|
||||||
readonly property int limitLongChatTextCompactMode: 1000
|
readonly property int limitLongChatTextCompactMode: 1000
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue