mirror of
https://github.com/timvisee/ffsend.git
synced 2025-10-06 02:29:57 +02:00
Sort history list, put first expiring last
This commit is contained in:
parent
77fb9c436d
commit
85e6e3da40
3 changed files with 15 additions and 5 deletions
|
@ -1,5 +1,4 @@
|
||||||
# Release 0.1
|
# Release 0.1
|
||||||
- Sort history entries
|
|
||||||
- Panic when secret is missing from URL with info action
|
- Panic when secret is missing from URL with info action
|
||||||
- History compiler flag
|
- History compiler flag
|
||||||
- Lowercase error messages
|
- Lowercase error messages
|
||||||
|
|
|
@ -167,9 +167,16 @@ impl RemoteFile {
|
||||||
&self.id
|
&self.id
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the duration the file will expire after,
|
/// Get the time the file will expire after.
|
||||||
/// if an expiry time is known.
|
/// Note that this time may not be correct as it may have been guessed,
|
||||||
/// Otherwise `None` is returned.
|
/// see `expire_uncertain()`.
|
||||||
|
pub fn expire_at(&self) -> DateTime<Utc> {
|
||||||
|
self.expire_at
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the duration the file will expire after.
|
||||||
|
/// Note that this time may not be correct as it may have been guessed,
|
||||||
|
/// see `expire_uncertain()`.
|
||||||
pub fn expire_duration(&self) -> Duration {
|
pub fn expire_duration(&self) -> Duration {
|
||||||
// Get the current time
|
// Get the current time
|
||||||
let now = Utc::now();
|
let now = Utc::now();
|
||||||
|
|
|
@ -66,8 +66,12 @@ impl<'a> History<'a> {
|
||||||
Cell::new("OWNER TOKEN"),
|
Cell::new("OWNER TOKEN"),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
// Get the list of files, and sort the first expiring files to be last
|
||||||
|
let mut files = history.files().clone();
|
||||||
|
files.sort_by(|a, b| b.expire_at().cmp(&a.expire_at()));
|
||||||
|
|
||||||
// Add an entry for each file
|
// Add an entry for each file
|
||||||
for (i, file) in history.files().iter().enumerate() {
|
for (i, file) in files.iter().enumerate() {
|
||||||
// Build the expiry time string
|
// Build the expiry time string
|
||||||
let mut expiry = format_duration(&file.expire_duration());
|
let mut expiry = format_duration(&file.expire_duration());
|
||||||
if file.expire_uncertain() {
|
if file.expire_uncertain() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue