mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-05 04:28:12 +08:00
Add a cancel transaction message to the history system (#3121)
Add cancel transaction Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
57111cff92
commit
7686edd47b
@@ -183,6 +183,7 @@ pub enum DocumentMessage {
|
|||||||
StartTransaction,
|
StartTransaction,
|
||||||
EndTransaction,
|
EndTransaction,
|
||||||
CommitTransaction,
|
CommitTransaction,
|
||||||
|
CancelTransaction,
|
||||||
AbortTransaction,
|
AbortTransaction,
|
||||||
RepeatedAbortTransaction {
|
RepeatedAbortTransaction {
|
||||||
undo_count: usize,
|
undo_count: usize,
|
||||||
|
|||||||
@@ -1286,16 +1286,20 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
|||||||
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
|
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
|
||||||
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
||||||
}
|
}
|
||||||
// Commits the transaction if the network was mutated since the transaction started, otherwise it aborts the transaction
|
// Commits the transaction if the network was mutated since the transaction started, otherwise it cancels the transaction
|
||||||
DocumentMessage::EndTransaction => match self.network_interface.transaction_status() {
|
DocumentMessage::EndTransaction => match self.network_interface.transaction_status() {
|
||||||
TransactionStatus::Started => {
|
TransactionStatus::Started => {
|
||||||
responses.add_front(DocumentMessage::AbortTransaction);
|
responses.add_front(DocumentMessage::CancelTransaction);
|
||||||
}
|
}
|
||||||
TransactionStatus::Modified => {
|
TransactionStatus::Modified => {
|
||||||
responses.add_front(DocumentMessage::CommitTransaction);
|
responses.add_front(DocumentMessage::CommitTransaction);
|
||||||
}
|
}
|
||||||
TransactionStatus::Finished => {}
|
TransactionStatus::Finished => {}
|
||||||
},
|
},
|
||||||
|
DocumentMessage::CancelTransaction => {
|
||||||
|
self.network_interface.finish_transaction();
|
||||||
|
self.document_undo_history.pop_back();
|
||||||
|
}
|
||||||
DocumentMessage::CommitTransaction => {
|
DocumentMessage::CommitTransaction => {
|
||||||
if self.network_interface.transaction_status() == TransactionStatus::Finished {
|
if self.network_interface.transaction_status() == TransactionStatus::Finished {
|
||||||
return;
|
return;
|
||||||
@@ -1304,9 +1308,15 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
|||||||
self.document_redo_history.clear();
|
self.document_redo_history.clear();
|
||||||
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
||||||
}
|
}
|
||||||
DocumentMessage::AbortTransaction => {
|
DocumentMessage::AbortTransaction => match self.network_interface.transaction_status() {
|
||||||
responses.add(DocumentMessage::RepeatedAbortTransaction { undo_count: 1 });
|
TransactionStatus::Started => {
|
||||||
}
|
responses.add_front(DocumentMessage::CancelTransaction);
|
||||||
|
}
|
||||||
|
TransactionStatus::Modified => {
|
||||||
|
responses.add(DocumentMessage::RepeatedAbortTransaction { undo_count: 1 });
|
||||||
|
}
|
||||||
|
TransactionStatus::Finished => {}
|
||||||
|
},
|
||||||
DocumentMessage::RepeatedAbortTransaction { undo_count } => {
|
DocumentMessage::RepeatedAbortTransaction { undo_count } => {
|
||||||
if self.network_interface.transaction_status() == TransactionStatus::Finished {
|
if self.network_interface.transaction_status() == TransactionStatus::Finished {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user