diff --git a/react-debug/src/App.css b/react-debug/src/App.css
index 74b5e05..a376606 100644
--- a/react-debug/src/App.css
+++ b/react-debug/src/App.css
@@ -36,3 +36,7 @@
transform: rotate(360deg);
}
}
+
+.figure {
+ width: 285px;
+}
diff --git a/react-debug/src/App.js b/react-debug/src/App.js
index d891b59..53134d4 100644
--- a/react-debug/src/App.js
+++ b/react-debug/src/App.js
@@ -1,5 +1,7 @@
import React from 'react';
+import './App.css';
+
class Album extends React.Component {
constructor(props) {
super(props);
@@ -25,18 +27,16 @@ class Album extends React.Component {
} else if (album !== null) {
console.log(album);
return album.map((a) => {
- let img =
;
- if (a.coverPhotoBaseUrl !== undefined) {
- img =
;
- }
-
- let figure =
- {img}
- { a.title || "No title" } - { a.mediaItemsCount || 0 } photos
- ;
- return
- { figure }
+ // TODO(wathiede): use coverPhotoMediaItemId and fetch from a
+ // locally cached image.
+ return
+
+
+
+ { a.filename}
+
+
});
} else {
return Loading...
;
diff --git a/src/main.rs b/src/main.rs
index 45e7f36..521fe86 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -123,8 +123,21 @@ impl<'a> Iterator for SearchIter<'a> {
}
}
-fn search_media_items(client: &photos::Client, album_id: String) -> Result<(), Box> {
- let mut total = 0;
+fn print_media_items(media_items: Vec) {
+ for mi in &media_items {
+ println!(
+ "{} {}",
+ mi.id.as_ref().unwrap_or(&"NO ID".to_string()),
+ mi.filename.as_ref().unwrap_or(&"NO FILENAME".to_string())
+ );
+ }
+ println!("({}) items total", media_items.len());
+}
+
+fn search_media_items(
+ client: &photos::Client,
+ album_id: String,
+) -> Result, Box> {
let media_items = SearchIter::new(
&client,
SearchMediaItemsRequest {
@@ -133,18 +146,10 @@ fn search_media_items(client: &photos::Client, album_id: String) -> Result<(), B
page_size: Some(100),
..Default::default()
},
- );
- for mi in media_items {
- let mi = mi?;
- total += 1;
- println!(
- "{} {}",
- mi.id.unwrap_or("NO ID".to_string()),
- mi.filename.unwrap_or("NO FILENAME".to_string())
- );
- }
- println!("({}) items total", total);
- Ok(())
+ )
+ .filter_map(|mi| mi.ok())
+ .collect();
+ Ok(media_items)
}
fn sync_albums(
@@ -159,11 +164,12 @@ fn sync_albums(
info!("making album directory {}", album_dir.to_string_lossy());
fs::create_dir_all(&album_dir)?;
}
- let j = serde_json::to_string(&albums)?;
+
+ let album = search_media_items(client, a.id.as_ref().expect("unset album id").to_string())?;
+ let j = serde_json::to_string(&album)?;
let path = album_dir.join("album.json");
info!("saving {}", path.to_string_lossy());
fs::write(path, j)?;
- search_media_items(client, a.id.as_ref().expect("unset album id").to_string());
}
// Serialize it to a JSON string.
let j = serde_json::to_string(&albums)?;
@@ -223,7 +229,10 @@ fn main() -> Result<(), Box> {
print_albums(list_albums(&client, title_filter)?);
Ok(())
}
- Command::SearchMediaItems { album_id } => search_media_items(&client, album_id),
+ Command::SearchMediaItems { album_id } => {
+ print_media_items(search_media_items(&client, album_id)?);
+ Ok(())
+ }
Command::Sync {
title_filter,
output,