Switch to an the updated emseries record type

This commit is contained in:
Savanni D'Gerinel 2023-12-27 17:14:47 -05:00
parent eae24ae313
commit ddb72d71d4
3 changed files with 31 additions and 6 deletions

View File

@ -14,7 +14,7 @@ General Public License for more details.
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>. You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>.
*/ */
use emseries::Series; use emseries::{Record, RecordId, Series};
use ft_core::TraxRecord; use ft_core::TraxRecord;
use std::{ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
@ -30,6 +30,12 @@ pub enum AppInvocation {
/// Request a set of records from the core. /// Request a set of records from the core.
// Note: this will require a time range, but doesn't yet. // Note: this will require a time range, but doesn't yet.
RequestRecords, RequestRecords,
UpdateRecord(Record<TraxRecord>),
PutRecord(TraxRecord),
DeleteRecord(RecordId),
} }
/// Responses are messages that the core sends to the UI. Though they are called responses, the /// Responses are messages that the core sends to the UI. Though they are called responses, the
@ -83,6 +89,27 @@ impl App {
AppResponse::Records AppResponse::Records
} }
} }
AppInvocation::UpdateRecord(record) => match *self.database.write().unwrap() {
Some(ref mut database) => {
database.update(record).unwrap();
AppResponse::Records
}
None => AppResponse::NoDatabase,
},
AppInvocation::PutRecord(record) => match *self.database.write().unwrap() {
Some(ref mut database) => {
database.put(record).unwrap();
AppResponse::Records
}
None => AppResponse::NoDatabase,
},
AppInvocation::DeleteRecord(record_id) => match *self.database.write().unwrap() {
Some(ref mut database) => {
database.delete(&record_id).unwrap();
AppResponse::Records
}
None => AppResponse::NoDatabase,
},
} }
} }

View File

@ -157,10 +157,10 @@ impl DayDetail {
}); });
let weight_view = match weight_record { let weight_view = match weight_record {
Some((unique_id, record)) => WeightView::new(Some(record), move |weight| { Some((id, record)) => WeightView::new(Some(record.clone()), move |weight| {
println!( println!(
"on_blur on the weight view. Need to record {:?}, {:?}", "on_blur on the weight view. Need to record {:?}, {:?}",
unique_id, weight id, weight
); );
}), }),
None => WeightView::new(None, |weight| { None => WeightView::new(None, |weight| {

View File

@ -1,6 +1,4 @@
use chrono::NaiveDate;
use dimensioned::si;
mod legacy; mod legacy;
mod types; mod types;
pub use types::{RecordType, Steps, TimeDistance, TraxRecord, Weight}; pub use types::{RecordType, Steps, TimeDistance, TraxRecord, Weight};