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