Ensure the text for the expire date spin box is updated even in situations when the expire date is forced back down to the same one being currently held

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-05-08 20:00:34 +08:00
parent aaeaad9918
commit da7d8c1f0a
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -111,7 +111,18 @@ Page {
}
function resetExpireDateField() {
// Expire date changing is handled by the expireDateSpinBox
// Expire date changing is handled through expireDateChanged listening in the expireDateSpinBox.
//
// When the user edits the expire date field they are changing the text, but the expire date
// value is only changed according to updates from the server.
//
// Sometimes the new expire date is the same -- say, because we were on the maximum allowed
// expire date already and we tried to push it beyond this, leading the server to just return
// the maximum allowed expire date.
//
// So to ensure that the text of the spin box is correctly updated, force an update of the
// contents of the expire date text field.
expireDateSpinBox.updateText();
waitingForExpireDateChange = false;
}
@ -671,6 +682,10 @@ Page {
SpinBox {
id: expireDateSpinBox
function updateText() {
expireDateSpinBoxTextField.text = textFromValue(value, locale);
}
// Work arounds the limitations of QML's 32 bit integer when handling msecs from epoch
// Instead, we handle everything as days since epoch
readonly property int dayInMSecs: 24 * 60 * 60 * 1000
@ -678,7 +693,7 @@ Page {
// Reset the model data after binding broken on user interact
onExpireDateReducedChanged: {
value = expireDateReduced;
expireDateSpinBoxTextField.text = textFromValue(value, locale);
updateText();
}
// We can't use JS's convenient Infinity or Number.MAX_VALUE as