Make document session history effects explicit

This commit is contained in:
2026-06-12 19:16:24 +02:00
parent a4cc251c68
commit 34a9e91099
5 changed files with 247 additions and 4 deletions

View File

@@ -1 +1,62 @@
#include "app_core/document_session.h"
namespace pp::app {
namespace {
[[nodiscard]] constexpr HistoryUiPlan make_history_clear_effect() noexcept
{
HistoryUiPlan plan;
plan.operation = HistoryUiOperation::clear;
plan.clears_history = true;
plan.updates_memory_label = true;
return plan;
}
[[nodiscard]] constexpr HistoryUiPlan make_history_no_op_effect() noexcept
{
HistoryUiPlan plan;
plan.operation = HistoryUiOperation::clear;
plan.no_op = true;
return plan;
}
} // namespace
HistoryUiPlan plan_document_open_history(const DocumentOpenRoute& route) noexcept
{
return route.kind == DocumentOpenKind::open_project
? make_history_clear_effect()
: make_history_no_op_effect();
}
HistoryUiPlan plan_close_request_history(CloseRequestDecision) noexcept
{
return make_history_no_op_effect();
}
HistoryUiPlan plan_document_save_history(DocumentSaveDecision) noexcept
{
return make_history_no_op_effect();
}
HistoryUiPlan plan_document_workflow_history(DocumentWorkflowDecision) noexcept
{
return make_history_no_op_effect();
}
HistoryUiPlan plan_document_file_save_history(const DocumentFileSavePlan&) noexcept
{
return make_history_no_op_effect();
}
HistoryUiPlan plan_document_version_save_history(const DocumentVersionTarget&) noexcept
{
return make_history_no_op_effect();
}
HistoryUiPlan plan_new_document_history(const NewDocumentPlan&) noexcept
{
return make_history_clear_effect();
}
} // namespace pp::app

View File

@@ -2,6 +2,7 @@
#include "app_core/app_dialog.h"
#include "app_core/document_route.h"
#include "app_core/history_ui.h"
#include "foundation/result.h"
#include <array>
@@ -144,6 +145,14 @@ public:
virtual void prompt_overwrite_new_document(const NewDocumentPlan& plan) = 0;
};
[[nodiscard]] HistoryUiPlan plan_document_open_history(const DocumentOpenRoute& route) noexcept;
[[nodiscard]] HistoryUiPlan plan_close_request_history(CloseRequestDecision decision) noexcept;
[[nodiscard]] HistoryUiPlan plan_document_save_history(DocumentSaveDecision decision) noexcept;
[[nodiscard]] HistoryUiPlan plan_document_workflow_history(DocumentWorkflowDecision decision) noexcept;
[[nodiscard]] HistoryUiPlan plan_document_file_save_history(const DocumentFileSavePlan& plan) noexcept;
[[nodiscard]] HistoryUiPlan plan_document_version_save_history(const DocumentVersionTarget& target) noexcept;
[[nodiscard]] HistoryUiPlan plan_new_document_history(const NewDocumentPlan& plan) noexcept;
[[nodiscard]] inline AppMessageDialogPlan plan_document_session_prompt(
DocumentSessionPromptKind kind,
std::string_view document_name = {})