Skip to content

Commit

Permalink
avoid reloading indexes unless they were updated by the transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
cfillion committed May 23, 2016
1 parent efa63eb commit 24b775f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/browser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Browser : public Dialog {
public:
Browser(ReaPack *);
void refresh(bool stale = false);
void populate();

protected:
void onInit() override;
Expand Down Expand Up @@ -98,7 +99,6 @@ class Browser : public Dialog {

Entry makeEntry(const Package *, const Registry::Entry &) const;

void populate();
void transferActions();
bool match(const Entry &) const;
void checkFilter();
Expand Down
12 changes: 9 additions & 3 deletions src/reapack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,17 @@ Transaction *ReaPack::setupTransaction()
});

m_tx->setCleanupHandler([=] {
// refresh only once all onFinish slots were ran
if(m_browser) {
// don't reload indexes unless they were modified
if(m_tx->updatedIndexes())
m_browser->refresh();
else
m_browser->populate();
}

delete m_tx;
m_tx = nullptr;

// refresh only once all onFinish slots were ran
refreshBrowser();
});

return m_tx;
Expand Down
1 change: 1 addition & 0 deletions src/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Transaction {
bool isCancelled() const { return m_isCancelled; }
const Receipt &receipt() const { return m_receipt; }
size_t taskCount() const { return m_tasks.size(); }
bool updatedIndexes() const { return !m_remotes.empty(); }

DownloadQueue *downloadQueue() { return &m_downloadQueue; }

Expand Down

0 comments on commit 24b775f

Please sign in to comment.