Commit f0672115 authored by Martin Straka's avatar Martin Straka
Browse files

Message can be deleted after 90 days only

parent 5795fb6d
......@@ -39,6 +39,8 @@ Component {
settingsButton.visible = false
}
}
property bool canDeleteMsg: false
property int deleteAfterDays: 90
Rectangle {
id: header2
anchors.top: parent.top
......@@ -299,6 +301,7 @@ Component {
}
MenuItem {
text: qsTr("Delete message")
enabled: canDeleteMsg
onTriggered: {
messages.deleteMessageFromDbs(gUserName, gMsgId, gMsgType)
}
......@@ -315,7 +318,23 @@ Component {
files.fillFileList(gUserName, rMsgId)
}
onPressAndHold: {
/* compare message delivery date with current date-90days */
function compareMsgDate(msgDeliveryTime) {
if (msgDeliveryTime == "") {
// message has virus or delivery time missing
return true
} else {
// convert qml date format to ISO date format
var inputDateFormat = /(\d{2})\.(\d{2})\.(\d{4})/;
var msgDate = new Date(msgDeliveryTime.replace(inputDateFormat,'$3-$2-$1'));
var today = new Date()
today.setDate(today.getDate()-deleteAfterDays)
// compare both dates in milliseconds
return (today.getTime() > msgDate.getTime())
}
}
gMsgId = rMsgId
canDeleteMsg = compareMsgDate(rDelivTime)
statusBar.visible = false
messageContextMenu.implicitWidth = computeMenuWidth(messageContextMenu)
// Located in left top corner.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment