mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-03 16:41:26 +01:00
feat(core,fuse,gui): "On this day" strip above the photos timeline
Add a PhotosOnThisDay control request, served from the stored timeline:
photos whose local capture date matches today's in earlier years, one
row per group. The GUI shows a card per year ("3 years ago") with the
year's newest photo as its cover; clicking a card scrolls the timeline
to that day. The strip is revealed only at the top of the whole,
unfiltered timeline, so it gives the grid its room back once you
scroll or filter.
This commit is contained in:
1 parent
c3ec82392a
commit
7dbf818d83
17 files changed
+2017
-1551
No files matched your search
@@ -84,6 +84,10 @@ pub enum Request {
|
||||
#[serde(default)]
|
||||
kind: Option<PhotoKind>,
|
||||
},
|
||||
/// Photos taken on today's date in earlier years, newest first, at most
|
||||
/// `limit` of them — the "On this day" strip above the timeline. Replies
|
||||
/// with [`Response::Photos`]; a front-end groups them by year itself.
|
||||
PhotosOnThisDay { limit: usize },
|
||||
/// List the account's photo albums, newest activity first, including the
|
||||
/// albums other people share with us. Metadata only — an album's cover
|
||||
/// thumbnail is fetched with [`Request::PhotoThumbs`] like any other photo.
|
||||
|
||||
@@ -588,6 +588,27 @@ impl Db {
|
||||
Ok(rows)
|
||||
}
|
||||
|
||||
/// Photos taken on `today`'s calendar day in earlier years, newest first —
|
||||
/// the "On this day" strip. `today` is epoch seconds: its local month and day
|
||||
/// pick the date, and its own year is left out, because today's photos are
|
||||
/// what the timeline already opens on. One row per group, like the timeline.
|
||||
pub fn photos_on_this_day(&self, today: i64, limit: usize) -> Result<Vec<StoredPhoto>> {
|
||||
let conn = self.read();
|
||||
let sql = format!(
|
||||
"{PHOTO_SELECT} WHERE p.uid = COALESCE(p.group_key, p.uid) \
|
||||
AND strftime('%m-%d', p.capture_time, 'unixepoch', 'localtime') \
|
||||
= strftime('%m-%d', ?1, 'unixepoch', 'localtime') \
|
||||
AND strftime('%Y', p.capture_time, 'unixepoch', 'localtime') \
|
||||
< strftime('%Y', ?1, 'unixepoch', 'localtime') \
|
||||
ORDER BY p.seq LIMIT ?2"
|
||||
);
|
||||
let mut stmt = conn.prepare(&sql)?;
|
||||
let rows = stmt
|
||||
.query_map(params![today, limit as i64], stored_photo)?
|
||||
.collect::<rusqlite::Result<_>>()?;
|
||||
Ok(rows)
|
||||
}
|
||||
|
||||
/// Per-tab counts for the Photos page subtitle: `(photos, videos, raw)`.
|
||||
pub fn photos_counts(&self) -> Result<(usize, usize, usize)> {
|
||||
use crate::control::PhotoKind;
|
||||
|
||||
@@ -253,6 +253,38 @@ fn favorites_are_remembered_across_refreshes_and_filter_a_page() {
|
||||
assert!(db.photos_by_uid(&["p2".into()]).unwrap()[0].favorite);
|
||||
}
|
||||
|
||||
/// The strip shows the same calendar day in earlier years only: not today's
|
||||
/// own photos, not the day before, and one tile per RAW+JPEG shot.
|
||||
#[test]
|
||||
fn on_this_day_finds_the_same_date_in_earlier_years() {
|
||||
const DAY: i64 = 86_400;
|
||||
// Noon UTC, so the local date is the same in every common time zone.
|
||||
let today = 1_781_524_800; // 2026-06-15 12:00 UTC
|
||||
let year_ago = today - 365 * DAY; // 2025-06-15
|
||||
let three_years_ago = today - (365 * 3 + 1) * DAY; // 2023-06-15, past a 29 February
|
||||
let db = Db::open_in_memory().unwrap();
|
||||
db.photos_replace(&[
|
||||
TimelineRow::new("today", today),
|
||||
TimelineRow {
|
||||
name: Some("IMG_1.JPG".into()),
|
||||
..TimelineRow::new("jpeg", year_ago)
|
||||
},
|
||||
TimelineRow {
|
||||
name: Some("IMG_1.CR2".into()),
|
||||
..TimelineRow::new("raw", year_ago)
|
||||
},
|
||||
TimelineRow::new("day-before", year_ago - DAY),
|
||||
TimelineRow::new("older", three_years_ago),
|
||||
])
|
||||
.unwrap();
|
||||
|
||||
let found = db.photos_on_this_day(today, 10).unwrap();
|
||||
assert_eq!(
|
||||
found.iter().map(|p| p.uid.as_str()).collect::<Vec<_>>(),
|
||||
["jpeg", "older"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn not_in_album_hides_photos_any_album_holds() {
|
||||
let db = Db::open_in_memory().unwrap();
|
||||
|
||||
Reference in new issue
Block a user