Skip to content

Commit

Permalink
Ensure the text for the expire date spin box is updated even in situa…
Browse files Browse the repository at this point in the history
…tions when the expire date is forced back down to the same one being currently held

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Jul 20, 2023
1 parent 10b323f commit f85f9a4
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/gui/filedetails/ShareDetailsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -671,14 +682,18 @@ 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
readonly property int expireDateReduced: Math.floor(root.expireDate / dayInMSecs)
// 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
Expand Down

0 comments on commit f85f9a4

Please sign in to comment.