From e9a0925bf34de20d0ad9c860edf3d5b08fe7b22f Mon Sep 17 00:00:00 2001 From: Daniel Leech Date: Thu, 30 May 2024 19:24:51 +0100 Subject: [PATCH] Marginally better support for description --- src/component/activity_view.rs | 8 +++++--- src/sync/convert.rs | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/component/activity_view.rs b/src/component/activity_view.rs index 6968734..05b88af 100644 --- a/src/component/activity_view.rs +++ b/src/component/activity_view.rs @@ -1,7 +1,7 @@ use tui::{ layout::{Constraint, Direction, Layout, Margin}, prelude::Buffer, - widgets::{Block, Borders, Widget}, + widgets::{Block, Borders, Widget, Paragraph}, }; use crate::{ @@ -78,13 +78,15 @@ impl View for ActivityView { fn draw(&mut self, app: &mut App, f: &mut Buffer, area: tui::layout::Rect) { let rows = Layout::default() .direction(Direction::Vertical) - .constraints([Constraint::Length(4), Constraint::Length(2)].as_ref()) + .constraints([Constraint::Length(3), Constraint::Min(1), Constraint::Length(2)].as_ref()) .split(area); if let Some(activity) = &app.activity { { let a = Activities::from(activity.clone()); activity_list_table(app, &a).render(rows[0], f); + let desc = Paragraph::new(activity.description.as_str()); + desc.render(rows[1], f); } } @@ -98,7 +100,7 @@ impl View for ActivityView { ] .as_ref(), ) - .split(rows[1]); + .split(rows[2]); let col1 = Layout::default() .direction(Direction::Vertical) .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref()) diff --git a/src/sync/convert.rs b/src/sync/convert.rs index 6cd3935..c273bad 100644 --- a/src/sync/convert.rs +++ b/src/sync/convert.rs @@ -37,7 +37,10 @@ impl ActivityConverter<'_> { for raw_activity in raw_activities { let listed: client::Activity = - serde_json::from_str(raw_activity.listed.as_str()).expect("Could not decode JSON"); + serde_json::from_str(match &raw_activity.activity { + Some(a) => &a.as_str(), + None => raw_activity.listed.as_str() + }).expect("Could not decode JSON"); self.logger.info(format!("Converting activity {}", listed.name)).await; let activity = Activity { id: listed.id,