From 8f2bb1aa7441c46f1bcbf8ab02437f08c9c9df17 Mon Sep 17 00:00:00 2001 From: Dmitry Vedenko Date: Thu, 15 Feb 2024 22:35:35 +0300 Subject: [PATCH] ReopenProject implemented --- .../mod-cloud-audiocom/CloudProjectUtils.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/modules/mod-cloud-audiocom/CloudProjectUtils.cpp b/modules/mod-cloud-audiocom/CloudProjectUtils.cpp index 6b03ad11b053..46e21c8f16c6 100644 --- a/modules/mod-cloud-audiocom/CloudProjectUtils.cpp +++ b/modules/mod-cloud-audiocom/CloudProjectUtils.cpp @@ -16,6 +16,7 @@ #include "CloudSyncService.h" #include "CodeConversions.h" #include "Project.h" +#include "ProjectFileIO.h" #include "ProjectFileManager.h" #include "ProjectManager.h" #include "ProjectWindow.h" @@ -24,8 +25,8 @@ #include "ui/dialogs/LinkFailedDialog.h" #include "ui/dialogs/ProjectVersionConflictDialog.h" -#include "ui/dialogs/UploadCanceledDialog.h" #include "ui/dialogs/UpdateCloudPreviewDialog.h" +#include "ui/dialogs/UploadCanceledDialog.h" #include "sync/LocalProjectSnapshot.h" #include "sync/MixdownUploader.h" @@ -295,7 +296,23 @@ bool ResaveLocally(AudacityProject& project) // TODO: Delete the old file immediately? return ProjectFileManager::Get(project).SaveAs(); } + void ReopenProject(AudacityProject& project) { + auto& projectCloudExtension = ProjectCloudExtension::Get(project); + + if (!projectCloudExtension.IsCloudProject()) + return; + + BasicUI::CallAfter( + [&project, + projectId = std::string(projectCloudExtension.GetCloudProjectId())] + { + auto newProject = ProjectManager::New(); + ProjectWindow::Get(project).Close(true); + OpenProjectFromCloud( + newProject, projectId, {}, + CloudSyncService::SyncMode::ForceOverwrite); + }); } } // namespace cloud::audiocom::sync