Clean up code
This commit is contained in:
parent
35a47704db
commit
48f789ca83
@ -4,7 +4,7 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use strum_macros::{EnumDiscriminants, EnumIter};
|
use strum_macros::{EnumDiscriminants, EnumIter};
|
||||||
|
|
||||||
pub trait PdfSheet {
|
pub trait PdfSheet {
|
||||||
@ -87,9 +87,7 @@ impl TryFrom<i64> for I64DateTime {
|
|||||||
|
|
||||||
fn try_from(value: i64) -> Result<Self, Self::Error> {
|
fn try_from(value: i64) -> Result<Self, Self::Error> {
|
||||||
Ok(I64DateTime(
|
Ok(I64DateTime(
|
||||||
NaiveDateTime::from_timestamp_opt(value, 0)
|
DateTime::<Utc>::from_timestamp(value, 0).ok_or("Failed converting i64 to DateTime")?,
|
||||||
.ok_or("Failed converting i64 to DateTime")?
|
|
||||||
.and_utc(),
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ use crate::{
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
mcdu::McduModel,
|
mcdu::McduModel,
|
||||||
sheet_edit_dialog::{SheetEditDialogInit, SheetEditDialogInput, SheetEditDialogModel},
|
sheet_edit_dialog::{SheetEditDialogInit, SheetEditDialogModel},
|
||||||
sheet_listing::{SheetListingInput, SheetListingModel, SheetListingOutput},
|
sheet_listing::{SheetListingInput, SheetListingModel, SheetListingOutput},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ impl AsyncComponent for AppModel {
|
|||||||
if self.edit_mode {
|
if self.edit_mode {
|
||||||
self.sheet_edit_dialog = Some(
|
self.sheet_edit_dialog = Some(
|
||||||
SheetEditDialogModel::builder()
|
SheetEditDialogModel::builder()
|
||||||
.transient_for(&root)
|
.transient_for(root)
|
||||||
.launch(SheetEditDialogInit {
|
.launch(SheetEditDialogInit {
|
||||||
sheet,
|
sheet,
|
||||||
database: Arc::clone(&self.database),
|
database: Arc::clone(&self.database),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use std::{borrow::BorrowMut, sync::Arc};
|
|
||||||
|
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use log::debug;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use relm4::{
|
use relm4::{
|
||||||
component::{AsyncComponent, AsyncComponentParts, Connector},
|
component::{AsyncComponent, AsyncComponentParts, Connector},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
@ -137,7 +136,7 @@ impl AsyncComponent for SheetEditDialogModel {
|
|||||||
crate::sheet::SheetKind::Book {
|
crate::sheet::SheetKind::Book {
|
||||||
name,
|
name,
|
||||||
composer_id,
|
composer_id,
|
||||||
sheet_ids,
|
sheet_ids: _,
|
||||||
} => {
|
} => {
|
||||||
is_book = true;
|
is_book = true;
|
||||||
sheet_name = name.to_string();
|
sheet_name = name.to_string();
|
||||||
@ -178,12 +177,12 @@ impl AsyncComponent for SheetEditDialogModel {
|
|||||||
async fn update(
|
async fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
msg: Self::Input,
|
msg: Self::Input,
|
||||||
sender: AsyncComponentSender<Self>,
|
_sender: AsyncComponentSender<Self>,
|
||||||
root: &Self::Root,
|
_root: &Self::Root,
|
||||||
) {
|
) {
|
||||||
match msg {
|
match msg {
|
||||||
SheetEditDialogInput::Accept => {
|
SheetEditDialogInput::Accept => {
|
||||||
if let Some(sheet) = &self.sheet {
|
if let Some(_sheet) = &self.sheet {
|
||||||
if self.sheet_name.is_empty() || self.sheet_composer.is_empty() {
|
if self.sheet_name.is_empty() || self.sheet_composer.is_empty() {
|
||||||
self.alert_empty_fields.emit(AlertMsg::Show);
|
self.alert_empty_fields.emit(AlertMsg::Show);
|
||||||
return;
|
return;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
|
||||||
use relm4::factory::{FactoryVecDeque, Position};
|
use relm4::factory::FactoryVecDeque;
|
||||||
use relm4::RelmListBoxExt;
|
use relm4::RelmListBoxExt;
|
||||||
use relm4::{gtk, ComponentParts, ComponentSender, SimpleComponent};
|
use relm4::{gtk, ComponentParts, ComponentSender, SimpleComponent};
|
||||||
|
|
||||||
@ -85,18 +85,18 @@ impl SimpleComponent for SheetListingModel {
|
|||||||
}
|
}
|
||||||
SheetListingInput::Sort => {
|
SheetListingInput::Sort => {
|
||||||
sort_sheets(&mut self.sheets);
|
sort_sheets(&mut self.sheets);
|
||||||
sender.output(SheetListingOutput::ContentsChanged);
|
sender.output(SheetListingOutput::ContentsChanged).unwrap();
|
||||||
}
|
}
|
||||||
SheetListingInput::Shuffle => {
|
SheetListingInput::Shuffle => {
|
||||||
shuffle_sheets(&mut self.sheets);
|
shuffle_sheets(&mut self.sheets);
|
||||||
sender.output(SheetListingOutput::ContentsChanged);
|
sender.output(SheetListingOutput::ContentsChanged).unwrap();
|
||||||
}
|
}
|
||||||
SheetListingInput::ReloadSheets(sheets) => {
|
SheetListingInput::ReloadSheets(sheets) => {
|
||||||
self.sheets.guard().clear();
|
self.sheets.guard().clear();
|
||||||
for sheet_model_type in sheets {
|
for sheet_model_type in sheets {
|
||||||
self.sheets.guard().push_back(sheet_model_type);
|
self.sheets.guard().push_back(sheet_model_type);
|
||||||
}
|
}
|
||||||
sender.output(SheetListingOutput::ContentsChanged);
|
sender.output(SheetListingOutput::ContentsChanged).unwrap();
|
||||||
}
|
}
|
||||||
SheetListingInput::None => {}
|
SheetListingInput::None => {}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user