Make the document auto-save system initially restore the last-viewed tab before loading the rest (#2194)

* Fixes last tab being opened instead of last active tab

Fixes https://discord.com/channels/731730685944922173/881073965047636018/937518022548131891

* Defers node initialisation to SelectDocument message instead of load_document

* Fix warning regarding attempt to load closed document

* Defer loading resources and running nodes to selection time

* Make last active tab load before others

* Load last active saved document instead of last autosaved doc

* Fix failing tests

* Code review

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
mTvare
2025-01-25 06:41:47 +00:00
committed by GitHub
co-authored by Keavon Chambers
parent de36d4967d
commit 9954e49530
9 changed files with 153 additions and 32 deletions
+5 -1
View File
@@ -299,7 +299,7 @@ impl EditorHandle {
}
#[wasm_bindgen(js_name = openAutoSavedDocument)]
pub fn open_auto_saved_document(&self, document_id: u64, document_name: String, document_is_saved: bool, document_serialized_content: String) {
pub fn open_auto_saved_document(&self, document_id: u64, document_name: String, document_is_saved: bool, document_serialized_content: String, to_front: bool) {
let document_id = DocumentId(document_id);
let message = PortfolioMessage::OpenDocumentFileWithId {
document_id,
@@ -307,6 +307,7 @@ impl EditorHandle {
document_is_auto_saved: true,
document_is_saved,
document_serialized_content,
to_front,
};
self.dispatch(message);
}
@@ -753,6 +754,7 @@ impl EditorHandle {
document_is_auto_saved,
document_is_saved,
document_serialized_content: document_serialized_content.clone(),
to_front: false,
});
let document = editor.dispatcher.message_handlers.portfolio_message_handler.active_document_mut().unwrap();
@@ -821,6 +823,7 @@ impl EditorHandle {
document_is_auto_saved,
document_is_saved,
document_serialized_content,
to_front: false,
});
return;
}
@@ -925,6 +928,7 @@ impl EditorHandle {
document_is_auto_saved,
document_is_saved,
document_serialized_content,
to_front: false,
});
}
}