Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions crates/app/src/host/message.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Host-service messages consumed by the native UI.

use std::path::PathBuf;

use uuid::Uuid;
Expand Down Expand Up @@ -28,7 +30,9 @@ pub enum HostMessage {
MultiSetupClose { id: Uuid },
/// The collected DLT statistics on a file for a SessionSetup
DltStatistics {
/// Setup tab that requested the statistics.
setup_session_id: Uuid,
/// Collected statistics, or `None` when collection failed.
statistics: Option<Box<DltStatistics>>,
},
/// A new session has been successfully created.
Expand All @@ -43,7 +47,12 @@ pub enum HostMessage {
/// Presets loaded from a file and ready for UI-side registry import.
PresetsImported(Box<PresetsImported>),
/// Presets were exported successfully to the provided file path.
PresetsExported { path: PathBuf, count: usize },
PresetsExported {
/// Destination file path.
path: PathBuf,
/// Number of exported presets.
count: usize,
},
/// A newer application version was found by the quiet startup update check.
AppVersionUpdate(Box<AppVersionUpdate>),
/// Result of an explicit user-triggered update check.
Expand All @@ -69,8 +78,19 @@ pub struct PresetsImported {
pub path: PathBuf,
/// Parsed presets ready to be inserted into the registry.
pub presets: Vec<Preset>,
/// True when the file was parsed through the legacy compatibility path.
pub used_legacy_format: bool,
/// Import format detected by the backend parser.
pub format: ImportFormat,
}

/// Import source recognized by the preset parser.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ImportFormat {
/// Native v1 Chipmunk named preset document.
Version1,
/// Native v2 Chipmunk named preset document.
Version2,
/// Legacy Chipmunk V3 TypeScript frontend export.
Legacy,
}

/// README loading result for a Plugin Manager request.
Expand Down
13 changes: 6 additions & 7 deletions crates/app/src/host/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{
common::{dlt_stats::dlt_statistics, parsers::ParserNames, sources::StreamNames},
communication::ServiceHandle,
error::HostError,
message::{HostMessage, PluginReadmeLoaded, PresetsImported},
message::{HostMessage, ImportFormat, PluginReadmeLoaded, PresetsImported},
notification::AppNotification,
service::storage::recent::RecentSessionOpenRequest,
ui::{
Expand All @@ -52,7 +52,7 @@ use crate::{
};

use plugin::{PluginEvent, PluginService};
use presets_io::{ImportFormat, import_named_presets, serialize_named_presets};
use presets_io::{import_named_presets, serialize_named_presets};
use storage::StorageService;

pub mod file;
Expand Down Expand Up @@ -822,7 +822,7 @@ impl HostService {
})
})??;

let used_legacy_format = match report.format {
match report.format {
ImportFormat::Legacy => {
for warning in &report.warnings {
trace!(
Expand All @@ -831,17 +831,16 @@ impl HostService {
warning
);
}
true
}
ImportFormat::Version1 => false,
};
ImportFormat::Version1 | ImportFormat::Version2 => {}
}

self.communication
.senders
.send_message(HostMessage::PresetsImported(Box::new(PresetsImported {
path,
presets: report.presets,
used_legacy_format,
format: report.format,
})))
.await;

Expand Down
Loading
Loading