Skip to content

Commit

Permalink
Merge pull request #55 from AnthonyMichaelTDM/issue-49
Browse files Browse the repository at this point in the history
issue 49
  • Loading branch information
AnthonyMichaelTDM authored Jun 23, 2024
2 parents d37e49a + 695d7e7 commit fe65957
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 21 deletions.
3 changes: 2 additions & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ macro_rules! function_name {
}};
}

pub(crate) fn format_duration(duration: &std::time::Duration) -> String {
#[must_use]
pub fn format_duration(duration: &std::time::Duration) -> String {
let total_seconds = duration.as_secs();
let hours = total_seconds / 3600;
let minutes = (total_seconds % 3600) / 60;
Expand Down
7 changes: 2 additions & 5 deletions tui/src/ui/components/content_view/views/album.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::{fmt::Display, sync::Mutex};

use crossterm::event::{KeyCode, KeyEvent};
use mecomp_core::format_duration;
use mecomp_storage::db::schemas::{album::Album, Thing};
use ratatui::{
layout::{Alignment, Constraint, Direction, Layout},
Expand Down Expand Up @@ -203,11 +204,7 @@ impl ComponentRender<RenderProps> for AlbumView {
),
Span::raw(" Duration: "),
Span::styled(
format!(
"{}:{:04.1}",
state.album.runtime.as_secs() / 60,
state.album.runtime.as_secs_f32() % 60.0,
),
format_duration(&state.album.runtime),
Style::default().italic(),
),
]),
Expand Down
7 changes: 2 additions & 5 deletions tui/src/ui/components/content_view/views/artist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::{fmt::Display, sync::Mutex};

use crossterm::event::{KeyCode, KeyEvent};
use mecomp_core::format_duration;
use mecomp_storage::db::schemas::{artist::Artist, Thing};
use ratatui::{
layout::{Alignment, Constraint, Direction, Layout},
Expand Down Expand Up @@ -190,11 +191,7 @@ impl ComponentRender<RenderProps> for ArtistView {
),
Span::raw(" Duration: "),
Span::styled(
format!(
"{}:{:04.1}",
state.artist.runtime.as_secs() / 60,
state.artist.runtime.as_secs_f32() % 60.0,
),
format_duration(&state.artist.runtime),
Style::default().italic(),
),
]),
Expand Down
7 changes: 2 additions & 5 deletions tui/src/ui/components/content_view/views/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use std::{fmt::Display, sync::Mutex};

use crossterm::event::{KeyCode, KeyEvent};
use mecomp_core::format_duration;
use mecomp_storage::db::schemas::{collection::Collection, Thing};
use ratatui::{
layout::{Alignment, Constraint, Direction, Layout},
Expand Down Expand Up @@ -183,11 +184,7 @@ impl ComponentRender<RenderProps> for CollectionView {
),
Span::raw(" Duration: "),
Span::styled(
format!(
"{}:{:04.1}",
state.collection.runtime.as_secs() / 60,
state.collection.runtime.as_secs_f32() % 60.0,
),
format_duration(&state.collection.runtime),
Style::default().italic(),
),
]),
Expand Down
7 changes: 2 additions & 5 deletions tui/src/ui/components/content_view/views/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::{fmt::Display, sync::Mutex};

use crossterm::event::{KeyCode, KeyEvent};
use mecomp_core::format_duration;
use mecomp_storage::db::schemas::{playlist::Playlist, Thing};
use ratatui::{
layout::{Alignment, Constraint, Direction, Layout},
Expand Down Expand Up @@ -230,11 +231,7 @@ impl ComponentRender<RenderProps> for PlaylistView {
),
Span::raw(" Duration: "),
Span::styled(
format!(
"{}:{:04.1}",
state.playlist.runtime.as_secs() / 60,
state.playlist.runtime.as_secs_f32() % 60.0,
),
format_duration(&state.playlist.runtime),
Style::default().italic(),
),
]),
Expand Down

0 comments on commit fe65957

Please sign in to comment.