Skip to content

Commit

Permalink
dev: Replace the usage of old Persistence.(34)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin42 committed Jan 10, 2024
1 parent f0ffa04 commit 14e1e88
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 53 deletions.
3 changes: 0 additions & 3 deletions PB/include/pb/PhotoBook.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ class Photobook final : public PBDev::Observer,

void newProject(std::string name);

void saveProject();
// todo: rename to renameProject
void saveProject(std::string name);
void loadProject();
void unloadProject();
bool isSaved();
Expand Down
2 changes: 1 addition & 1 deletion PB/include/pb/project/Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Project final {
~Project() = default;

ProjectMetadata const &metadata() { return mMetadata; }
ProjectSnapshot &active() { return mActive; }
ProjectSnapshot const &active() { return mActive; }
ProjectSnapshot const &cache() { return mCache; }

void sync() { mCache = mActive; }
Expand Down
31 changes: 1 addition & 30 deletions PB/src/PhotoBook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,35 +174,6 @@ void Photobook::exportAlbum(std::string name, Path path)

ProjectPersistence &Photobook::project() { return mProjectPersistence; }

void Photobook::saveProject()
{
saveProject(mProjectPersistence.currentProject()->cache().name);
}

void Photobook::saveProject(std::string name)
{
auto project = mProjectPersistence.currentProject();
auto oldName = project->cache().name;

project->sync();

Path projectPath = VirtualImage::platformInfo->localStatePath /
(name + Context::BOOK_EXTENSION);

auto uuidStr = boost::uuids::to_string(project->active().uuid);
auto fullPath = project->metadata().projectFile();
PB::ProjectMetadata projectMetadata(uuidStr, projectPath.string());

// mPersistence.persistProject(name, project->active());
// mPersistence.persistMetadata(projectMetadata);

if (name != oldName) {
Path oldProjectPath = VirtualImage::platformInfo->localStatePath /
(oldName + Context::BOOK_EXTENSION);
// mPersistence.deleteProject(oldProjectPath);
}
}

ImageViews &Photobook::imageViews() { return mImageViews; }

void Photobook::onProjectRead()
Expand All @@ -222,7 +193,7 @@ void Photobook::newProject(std::string name)
{
configure(std::make_shared<Project>(name));

saveProject();
//saveProject();
}

void Photobook::onMappingStarted(Path path) { mParent->onMappingStarted(path); }
Expand Down
21 changes: 2 additions & 19 deletions windows/PhotobookUI/TableContentPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,27 +278,10 @@ void TableContentPage::OnSaveClicked(
[[maybe_unused]] Windows::Foundation::IInspectable const &sender,
[[maybe_unused]] Microsoft::UI::Xaml::RoutedEventArgs const &args)
{
auto projectDetails = mPhotoBook->project().currentProject()->active();
bool alreadySaved =
true; // mPhotoBook->persistence()->isSaved(projectDetails);
if (alreadySaved) {
if (mPhotoBook->project().currentProject()->isSynced()) {
return;
}
mPhotoBook->saveProject();
RenameProjectDialogDisplay();
/*
mPopups.fireSaveFilePicker(
MainWindow::sMainWindowHandle,
[this](std::variant<std::string, PBDev::Error> result) {
if (std::holds_alternative<std::string>(result)) {
auto &newName = std::get<std::string>(result);
mPhotoBook->saveProject(newName);
}
else {
OnError(std::get<PBDev::Error>(result));
}
});
*/
mPhotoBook->project().save();
}

void TableContentPage::OnSaveAsClicked(
Expand Down

0 comments on commit 14e1e88

Please sign in to comment.