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:
parent
57111cff92
commit
7686edd47b
|
|
@ -183,6 +183,7 @@ pub enum DocumentMessage {
|
|||
StartTransaction,
|
||||
EndTransaction,
|
||||
CommitTransaction,
|
||||
CancelTransaction,
|
||||
AbortTransaction,
|
||||
RepeatedAbortTransaction {
|
||||
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
|
||||
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() {
|
||||
TransactionStatus::Started => {
|
||||
responses.add_front(DocumentMessage::AbortTransaction);
|
||||
responses.add_front(DocumentMessage::CancelTransaction);
|
||||
}
|
||||
TransactionStatus::Modified => {
|
||||
responses.add_front(DocumentMessage::CommitTransaction);
|
||||
}
|
||||
TransactionStatus::Finished => {}
|
||||
},
|
||||
DocumentMessage::CancelTransaction => {
|
||||
self.network_interface.finish_transaction();
|
||||
self.document_undo_history.pop_back();
|
||||
}
|
||||
DocumentMessage::CommitTransaction => {
|
||||
if self.network_interface.transaction_status() == TransactionStatus::Finished {
|
||||
return;
|
||||
|
|
@ -1304,9 +1308,15 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
|
|||
self.document_redo_history.clear();
|
||||
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
|
||||
}
|
||||
DocumentMessage::AbortTransaction => {
|
||||
responses.add(DocumentMessage::RepeatedAbortTransaction { undo_count: 1 });
|
||||
}
|
||||
DocumentMessage::AbortTransaction => match self.network_interface.transaction_status() {
|
||||
TransactionStatus::Started => {
|
||||
responses.add_front(DocumentMessage::CancelTransaction);
|
||||
}
|
||||
TransactionStatus::Modified => {
|
||||
responses.add(DocumentMessage::RepeatedAbortTransaction { undo_count: 1 });
|
||||
}
|
||||
TransactionStatus::Finished => {}
|
||||
},
|
||||
DocumentMessage::RepeatedAbortTransaction { undo_count } => {
|
||||
if self.network_interface.transaction_status() == TransactionStatus::Finished {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue