Skip to content

Commit

Permalink
Marginally better support for description
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech committed May 30, 2024
1 parent 44a1355 commit e9a0925
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/component/activity_view.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use tui::{
layout::{Constraint, Direction, Layout, Margin},
prelude::Buffer,
widgets::{Block, Borders, Widget},
widgets::{Block, Borders, Widget, Paragraph},
};

use crate::{
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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())
Expand Down
5 changes: 4 additions & 1 deletion src/sync/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e9a0925

Please sign in to comment.