mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-10-17 08:42:28 +00:00
use history variant
This commit is contained in:
1 parent
187296a277
commit
1bfd319758
14 files changed
+181
-121
No files matched your search
@@ -139,12 +139,12 @@ pub fn create_artificial_timestamps(
|
||||
|
||||
#[tauri::command(async)]
|
||||
pub fn merge(state: State<AppState>, merge_type: MergeType, remove_gaps: bool) -> api::Outcome {
|
||||
state.run(move |e| api::merge(e, merge_type, remove_gaps, false))
|
||||
state.run(move |e| api::merge(e, merge_type, remove_gaps))
|
||||
}
|
||||
|
||||
#[tauri::command(async)]
|
||||
pub fn extract(state: State<AppState>) -> api::Outcome {
|
||||
state.run(|e| api::extract(e, false))
|
||||
state.run(api::extract)
|
||||
}
|
||||
|
||||
#[tauri::command(async)]
|
||||
@@ -214,5 +214,5 @@ pub fn split(
|
||||
at: u32,
|
||||
split_type: SplitType,
|
||||
) -> api::Outcome {
|
||||
state.run(move |e| api::split(e, revision, at, split_type, false))
|
||||
state.run(move |e| api::split(e, revision, at, split_type))
|
||||
}
|
||||
@@ -10,6 +10,10 @@ mod workspace;
|
||||
use commands::*;
|
||||
use tauri::{Emitter, Manager};
|
||||
|
||||
/// The engine of the app: each file has its own history, so that undoing only concerns the
|
||||
/// selected files, and opening or closing a file is not something to undo.
|
||||
pub(crate) type Engine = gpx_engine::Engine<gpx_engine::PerFileHistory>;
|
||||
|
||||
/// The GPX files among what the system gave to the app (the arguments of the command line, when a
|
||||
/// file is opened with it).
|
||||
fn gpx_paths(arguments: impl IntoIterator<Item = String>) -> Vec<std::path::PathBuf> {
|
||||
|
||||
+2
-1
@@ -11,7 +11,8 @@ use std::sync::{Arc, Mutex};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use gpx_engine::{Engine, Persister, Storage, api};
|
||||
use crate::Engine;
|
||||
use gpx_engine::{Persister, Storage, api};
|
||||
use notify::RecursiveMode;
|
||||
use notify_debouncer_mini::{DebounceEventResult, Debouncer, new_debouncer};
|
||||
use serde::Serialize;
|
||||
|
||||
+3
-2
@@ -220,7 +220,8 @@ impl Storage for FileStorage {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use gpx_engine::{Action, Command, Engine, Load, LoadFiles, Persister};
|
||||
use crate::Engine;
|
||||
use gpx_engine::{Action, Command, Load, LoadFiles, Persister};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -255,7 +256,7 @@ mod tests {
|
||||
// another session
|
||||
let storage = FileStorage::open(&root).unwrap();
|
||||
let restored = pollster::block_on(Persister::default().restore(&storage)).unwrap();
|
||||
let mut other: Engine = Engine::default();
|
||||
let mut other = Engine::default();
|
||||
other.restore(restored);
|
||||
assert_eq!(other.order(), order);
|
||||
assert_eq!(
|
||||
|
||||
+8
-3
@@ -165,7 +165,8 @@ fn edits_undoes_and_selects() {
|
||||
json!({ "name": "route", "lng": 4.4, "lat": 50.8 }),
|
||||
);
|
||||
assert_eq!(outcome["changed"], true);
|
||||
assert_eq!(app.call("can_undo", json!({})), true);
|
||||
// each file has its own history, which starts when it appears
|
||||
assert_eq!(app.call("can_undo", json!({})), false);
|
||||
|
||||
let id = app.call("file_order", json!({}))[0].clone();
|
||||
let outcome = app.call("metadata", json!({ "name": "renamed", "desc": "" }));
|
||||
@@ -179,6 +180,7 @@ fn edits_undoes_and_selects() {
|
||||
assert_eq!(outcome["selectionChanged"], true);
|
||||
assert_eq!(app.call("selection", json!({})), json!({ "type": "empty" }));
|
||||
app.call("select", json!({ "fileIds": [id], "mode": "toggle" }));
|
||||
assert_eq!(app.call("can_undo", json!({})), true);
|
||||
|
||||
app.call("undo", json!({}));
|
||||
assert_eq!(
|
||||
@@ -186,8 +188,11 @@ fn edits_undoes_and_selects() {
|
||||
"route"
|
||||
);
|
||||
assert_eq!(app.call("can_redo", json!({})), true);
|
||||
app.call("undo", json!({}));
|
||||
assert_eq!(app.call("file_order", json!({})), json!([]));
|
||||
// creating the file is not something to undo
|
||||
assert_eq!(app.call("can_undo", json!({})), false);
|
||||
let outcome = app.call("undo", json!({}));
|
||||
assert_eq!(outcome["changed"], false);
|
||||
assert_eq!(app.call("file_order", json!({})), json!([id]));
|
||||
|
||||
// what cannot be done says why
|
||||
let outcome = app.call("reverse", json!({}));
|
||||
|
||||
@@ -18,7 +18,8 @@ use std::collections::BTreeMap;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use gpx_engine::{Engine, ExportOptions, FileId, api};
|
||||
use crate::Engine;
|
||||
use gpx_engine::{ExportOptions, FileId, api};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
|
||||
Reference in new issue
Block a user