mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 21:37:59 +00:00
Remove GRAPHITE_DOCUMENT_VERSION
This commit is contained in:
parent
121c1d2b9d
commit
7998947202
10 changed files with 8 additions and 45 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -81,7 +81,6 @@ pub const DEFAULT_FONT_FAMILY: &str = "Cabin";
|
|||
pub const DEFAULT_FONT_STYLE: &str = "Normal (400)";
|
||||
|
||||
// Document
|
||||
pub const GRAPHITE_DOCUMENT_VERSION: &str = "0.1.2"; // Remember to update the demo artwork in /demos with both this version number and the contents so it remains editable
|
||||
pub const DEFAULT_DOCUMENT_NAME: &str = "Untitled Document";
|
||||
pub const FILE_SAVE_SUFFIX: &str = ".graphite";
|
||||
pub const MAX_UNDO_HISTORY_LEN: usize = 100; // TODO: Add this to user preferences
|
||||
|
|
|
@ -450,9 +450,8 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
/// If this test is failing take a look at `GRAPHITE_DOCUMENT_VERSION` in `editor/src/consts.rs`, it may need to be updated.
|
||||
/// This test will fail when you make changes to the underlying serialization format for a document.
|
||||
fn check_if_graphite_file_version_upgrade_is_needed() {
|
||||
fn check_if_demo_art_opens() {
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
|
||||
let print_problem_to_terminal_on_failure = |value: &String| {
|
||||
|
@ -460,10 +459,6 @@ mod test {
|
|||
println!("-------------------------------------------------");
|
||||
println!("Failed test due to receiving a DisplayDialogError while loading a Graphite demo file.");
|
||||
println!();
|
||||
println!("That probably means the document serialization format changed. In that case, you need to bump the constant value");
|
||||
println!("`GRAPHITE_DOCUMENT_VERSION` in `editor/src/consts.rs`, then update the documents in `/demo-artwork` by editing");
|
||||
println!("their JSON to ensure they remain compatible with both the bumped version number and the serialization format changes.");
|
||||
println!();
|
||||
println!("DisplayDialogError details:");
|
||||
println!();
|
||||
println!("Description: {value}");
|
||||
|
|
|
@ -85,7 +85,6 @@ pub enum FrontendMessage {
|
|||
TriggerIndexedDbWriteDocument {
|
||||
document: String,
|
||||
details: FrontendDocumentDetails,
|
||||
version: String,
|
||||
},
|
||||
TriggerLoadAutoSaveDocuments,
|
||||
TriggerLoadPreferences,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::utility_types::error::EditorError;
|
||||
use super::utility_types::misc::{SnappingOptions, SnappingState};
|
||||
use crate::application::{generate_uuid, GRAPHITE_GIT_COMMIT_HASH};
|
||||
use crate::consts::{ASYMPTOTIC_EFFECT, DEFAULT_DOCUMENT_NAME, FILE_SAVE_SUFFIX, GRAPHITE_DOCUMENT_VERSION, SCALE_EFFECT, SCROLLBAR_SPACING};
|
||||
use crate::consts::{ASYMPTOTIC_EFFECT, DEFAULT_DOCUMENT_NAME, FILE_SAVE_SUFFIX, SCALE_EFFECT, SCROLLBAR_SPACING};
|
||||
use crate::messages::input_mapper::utility_types::macros::action_keys;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::portfolio::document::node_graph::NodeGraphHandlerData;
|
||||
|
@ -50,8 +50,6 @@ pub struct DocumentMessageHandler {
|
|||
pub network: NodeNetwork,
|
||||
#[serde(default = "default_name")]
|
||||
pub name: String,
|
||||
#[serde(default = "default_version")]
|
||||
version: String,
|
||||
#[serde(default = "default_commit_hash")]
|
||||
commit_hash: String,
|
||||
#[serde(default = "default_pan_tilt_zoom")]
|
||||
|
@ -105,7 +103,6 @@ impl Default for DocumentMessageHandler {
|
|||
// ============================================
|
||||
network: root_network(),
|
||||
name: DEFAULT_DOCUMENT_NAME.to_string(),
|
||||
version: GRAPHITE_DOCUMENT_VERSION.to_string(),
|
||||
commit_hash: GRAPHITE_GIT_COMMIT_HASH.to_string(),
|
||||
navigation: PTZ::default(),
|
||||
document_mode: DocumentMode::DesignMode,
|
||||
|
@ -138,10 +135,6 @@ fn default_name() -> String {
|
|||
DocumentMessageHandler::default().name
|
||||
}
|
||||
#[inline(always)]
|
||||
fn default_version() -> String {
|
||||
DocumentMessageHandler::default().version
|
||||
}
|
||||
#[inline(always)]
|
||||
fn default_commit_hash() -> String {
|
||||
DocumentMessageHandler::default().commit_hash
|
||||
}
|
||||
|
@ -879,17 +872,7 @@ impl DocumentMessageHandler {
|
|||
}
|
||||
|
||||
pub fn deserialize_document(serialized_content: &str) -> Result<Self, EditorError> {
|
||||
let deserialized_result: Result<Self, EditorError> = serde_json::from_str(serialized_content).map_err(|e| EditorError::DocumentDeserialization(e.to_string()));
|
||||
match deserialized_result {
|
||||
Ok(document) => {
|
||||
if document.version == GRAPHITE_DOCUMENT_VERSION {
|
||||
Ok(document)
|
||||
} else {
|
||||
Err(EditorError::DocumentDeserialization("Graphite document version mismatch".to_string()))
|
||||
}
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
serde_json::from_str(serialized_content).map_err(|e| EditorError::DocumentDeserialization(e.to_string()))
|
||||
}
|
||||
|
||||
pub fn with_name(name: String, ipp: &InputPreprocessorMessageHandler, responses: &mut VecDeque<Message>) -> Self {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::utility_types::PersistentData;
|
||||
use crate::application::generate_uuid;
|
||||
use crate::consts::{DEFAULT_DOCUMENT_NAME, GRAPHITE_DOCUMENT_VERSION};
|
||||
use crate::consts::DEFAULT_DOCUMENT_NAME;
|
||||
use crate::messages::dialog::simple_dialogs;
|
||||
use crate::messages::frontend::utility_types::FrontendDocumentDetails;
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
|
@ -90,7 +90,6 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
id: document_id,
|
||||
name: document.name.clone(),
|
||||
},
|
||||
version: GRAPHITE_DOCUMENT_VERSION.to_string(),
|
||||
})
|
||||
}
|
||||
PortfolioMessage::CloseActiveDocumentWithConfirmation => {
|
||||
|
|
|
@ -51,13 +51,7 @@ export function createPersistenceManager(editor: Editor, portfolio: PortfolioSta
|
|||
|
||||
const orderedSavedDocuments = documentOrder.flatMap((id) => (previouslySavedDocuments[id] ? [previouslySavedDocuments[id]] : []));
|
||||
|
||||
const currentDocumentVersion = editor.instance.graphiteDocumentVersion();
|
||||
orderedSavedDocuments?.forEach(async (doc: TriggerIndexedDbWriteDocument) => {
|
||||
if (doc.version !== currentDocumentVersion) {
|
||||
await removeDocument(doc.details.id);
|
||||
return;
|
||||
}
|
||||
|
||||
editor.instance.openAutoSavedDocument(BigInt(doc.details.id), doc.details.name, doc.details.isSaved, doc.document);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use crate::{Error, EDITOR_HAS_CRASHED, EDITOR_INSTANCES, JS_EDITOR_HANDLES};
|
|||
|
||||
use editor::application::generate_uuid;
|
||||
use editor::application::Editor;
|
||||
use editor::consts::{FILE_SAVE_SUFFIX, GRAPHITE_DOCUMENT_VERSION};
|
||||
use editor::consts::FILE_SAVE_SUFFIX;
|
||||
use editor::messages::input_mapper::utility_types::input_keyboard::ModifierKeys;
|
||||
use editor::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta, ViewportBounds};
|
||||
use editor::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
||||
|
@ -270,12 +270,6 @@ impl JsEditorHandle {
|
|||
FILE_SAVE_SUFFIX.into()
|
||||
}
|
||||
|
||||
/// Get the constant `GRAPHITE_DOCUMENT_VERSION`
|
||||
#[wasm_bindgen(js_name = graphiteDocumentVersion)]
|
||||
pub fn graphite_document_version(&self) -> String {
|
||||
GRAPHITE_DOCUMENT_VERSION.to_string()
|
||||
}
|
||||
|
||||
/// Update layout of a given UI
|
||||
#[wasm_bindgen(js_name = updateLayout)]
|
||||
pub fn update_layout(&self, layout_target: JsValue, widget_id: u64, value: JsValue) -> Result<(), JsValue> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue