MCPcopy Create free account
hub / github.com/YtFlow/Maple / SaveButton_Click

Method SaveButton_Click

Maple.App/EditPage.cpp:64–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62 }
63 }
64 fire_and_forget EditPage::SaveButton_Click(IInspectable const& sender, RoutedEventArgs const&) {
65 try {
66 const auto lifetime = get_strong();
67 const auto& placementTarget = sender.try_as<FrameworkElement>();
68 const auto currentValidateRequest = ++validateRequest;
69 ValidConfigFlyout().Hide();
70 InvalidConfigFlyout().Hide();
71 co_await SaveDocument();
72 if (validateRequest != currentValidateRequest) {
73 co_return;
74 }
75
76 // Validate
77 const auto& path = winrt::to_string(m_file.Path());
78 co_await winrt::resume_background();
79 const auto result = leaf_test_config(path.data());
80 co_await winrt::resume_foreground(Dispatcher());
81 if (validateRequest != currentValidateRequest) {
82 co_return;
83 }
84 switch (result)
85 {
86 case LEAF_ERR_OK:
87 ValidConfigFlyout().ShowAt(placementTarget);
88 break;
89 case LEAF_ERR_CONFIG:
90 InvalidConfigFlyout().ShowAt(placementTarget);
91 break;
92 default:
93 // TODO: handle errors
94 break;
95 }
96 co_await winrt::resume_after(2s);
97 co_await winrt::resume_foreground(Dispatcher());
98 if (validateRequest != currentValidateRequest) {
99 co_return;
100 }
101 ValidConfigFlyout().Hide();
102 InvalidConfigFlyout().Hide();
103 }
104 catch (...)
105 {
106 UI::NotifyException(L"Saving file");
107 }
108 }
109 void EditPage::HelpButton_Click(IInspectable const&, RoutedEventArgs const&) {
110 const auto _ = winrt::Windows::System::Launcher::LaunchUriAsync(Uri{ L"https://github.com/eycorsican/leaf/blob/master/README.zh.md" });
111 }

Callers

nothing calls this directly

Calls 1

dataMethod · 0.80

Tested by

no test coverage detected