Improve "Recover Files" UI (related issues #4130, #5513)#5805
Conversation
* Show "Active Session" with closed docs (in memory) and backups (in disk) * Show all sessions in date order (crashed and correcly closed)
aseprite-bot
left a comment
There was a problem hiding this comment.
clang-tidy made some suggestions
| ASSERT(doc->context() == nullptr); | ||
|
|
||
| ClosedDoc closedDoc = { doc, base::current_tick() }; | ||
| ObjectId docId = doc->id(); |
There was a problem hiding this comment.
warning: variable 'docId' of type 'ObjectId' (aka 'unsigned int') can be declared 'const' [misc-const-correctness]
| ObjectId docId = doc->id(); | |
| ObjectId const docId = doc->id(); |
| std::unique_lock<std::mutex> lock(m_mutex); | ||
| m_docs.insert(m_docs.begin(), std::move(closedDoc)); | ||
| { | ||
| std::unique_lock<std::mutex> lock(m_mutex); |
There was a problem hiding this comment.
warning: variable 'lock' of type 'std::unique_lockstd::mutex' can be declared 'const' [misc-const-correctness]
| std::unique_lock<std::mutex> lock(m_mutex); | |
| std::unique_lock<std::mutex> const lock(m_mutex); |
| { | ||
| Doc* doc = nullptr; | ||
| { | ||
| std::unique_lock<std::mutex> lock(m_mutex); |
There was a problem hiding this comment.
warning: variable 'lock' of type 'std::unique_lockstd::mutex' can be declared 'const' [misc-const-correctness]
| std::unique_lock<std::mutex> lock(m_mutex); | |
| std::unique_lock<std::mutex> const lock(m_mutex); |
| { | ||
| std::vector<crash::DocumentInfo> infos; | ||
| { | ||
| std::unique_lock<std::mutex> lock(m_mutex); |
There was a problem hiding this comment.
warning: variable 'lock' of type 'std::unique_lockstd::mutex' can be declared 'const' [misc-const-correctness]
| std::unique_lock<std::mutex> lock(m_mutex); | |
| std::unique_lock<std::mutex> const lock(m_mutex); |
| bool hasClosedDocs(); | ||
| void addClosedDoc(Doc* doc); | ||
| Doc* reopenLastClosedDoc(); | ||
| Doc* reopenClosedDocById(const doc::ObjectId docId); |
There was a problem hiding this comment.
warning: parameter 'docId' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
| Doc* reopenClosedDocById(const doc::ObjectId docId); | |
| Doc* reopenClosedDocById(doc::ObjectId docId); |
| { | ||
| DATAVIEW_TRACE("DATAVIEW: onNewClosedDoc", (int)docId); | ||
|
|
||
| int i = parent()->getChildIndex(this); |
There was a problem hiding this comment.
warning: variable 'i' of type 'int' can be declared 'const' [misc-const-correctness]
| int i = parent()->getChildIndex(this); | |
| int const i = parent()->getChildIndex(this); |
| updateNoClosedDocVisibility(); | ||
| } | ||
|
|
||
| void onArchiveClosedDoc(doc::ObjectId docId, const bool backedup) override |
There was a problem hiding this comment.
warning: parameter 'backedup' is unused [misc-unused-parameters]
| void onArchiveClosedDoc(doc::ObjectId docId, const bool backedup) override | |
| void onArchiveClosedDoc(doc::ObjectId docId, const bool /*backedup*/) override |
|
|
||
| onReopenClosedDoc(docId); | ||
|
|
||
| int index = clearBackups(parent()); |
There was a problem hiding this comment.
warning: variable 'index' of type 'int' can be declared 'const' [misc-const-correctness]
| int index = clearBackups(parent()); | |
| int const index = clearBackups(parent()); |
| int countItemsInThisSection() | ||
| { | ||
| int itemsInThisSection = 0; | ||
| int n = int(parent()->children().size()); |
There was a problem hiding this comment.
warning: variable 'n' of type 'int' can be declared 'const' [misc-const-correctness]
| int n = int(parent()->children().size()); | |
| int const n = int(parent()->children().size()); |
| } | ||
|
|
||
| void DataRecoveryView::onOpen() | ||
| WidgetsList DataRecoveryView::selectedItems() |
There was a problem hiding this comment.
warning: method 'selectedItems' can be made static [readability-convert-member-functions-to-static]
src/app/ui/data_recovery_view.h:58:
- ui::WidgetsList selectedItems();
+ static ui::WidgetsList selectedItems();|
Perfect! It works great, I like it. The only note is: "in memory" implies that the sprite is still in RAM, which is correct, but perhaps it would be better to report "undo history" or "w/undo history" or "can undo" to express the advantages of "in memory". |
I thought something similar, but I'm as #3718 is planned, the idea is that after that all backups (even the one in disk) will contain the undo information. |
|
One thing I don't like is when both versions appear: the one in memory (with undo) and the one in disk (without undo, at the moment). So probably just hiding the one in disk while we have the one in memory would be enough to avoid confusion to the user. |
This PR adds the "Active Session" in the "Recover Files" tab:
When we close a sprite:
When a version of the sprite is fully backed up in disk and we close the sprite we can see both versions (the one closed still in memory with undo info, and the backed up sprite in disk):
After the file in memory is freed only the backed up data is displayed: