Fixed crashes during infinite scrolling, ref #83
This commit is contained in:
+27
-12
@@ -66,16 +66,7 @@ PlayQueue::PlayQueue()
|
|||||||
});
|
});
|
||||||
|
|
||||||
_entriesContainer = bindNew<Wt::WContainerWidget>("entries");
|
_entriesContainer = bindNew<Wt::WContainerWidget>("entries");
|
||||||
|
hideLoadingIndicator();
|
||||||
_loadingIndicator = bindWidget<Wt::WTemplate>("loading-indicator", createLoadingIndicator());
|
|
||||||
_loadingIndicator->scrollVisibilityChanged().connect([this](bool visible)
|
|
||||||
{
|
|
||||||
if (!visible)
|
|
||||||
return;
|
|
||||||
|
|
||||||
addSome();
|
|
||||||
updateCurrentTrack(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
Wt::WText* shuffleBtn = bindNew<Wt::WText>("shuffle-btn", Wt::WString::tr("Lms.PlayQueue.template.shuffle-btn"), Wt::TextFormat::XHTML);
|
Wt::WText* shuffleBtn = bindNew<Wt::WText>("shuffle-btn", Wt::WString::tr("Lms.PlayQueue.template.shuffle-btn"), Wt::TextFormat::XHTML);
|
||||||
setToolTip(*shuffleBtn, Wt::WString::tr("Lms.PlayQueue.shuffle"));
|
setToolTip(*shuffleBtn, Wt::WString::tr("Lms.PlayQueue.shuffle"));
|
||||||
@@ -191,6 +182,27 @@ PlayQueue::updateRadioBtn()
|
|||||||
_radioBtn->toggleStyleClass("text-muted", !_radioMode);
|
_radioBtn->toggleStyleClass("text-muted", !_radioMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlayQueue::displayLoadingIndicator()
|
||||||
|
{
|
||||||
|
_loadingIndicator = bindWidget<Wt::WTemplate>("loading-indicator", createLoadingIndicator());
|
||||||
|
_loadingIndicator->scrollVisibilityChanged().connect([this](bool visible)
|
||||||
|
{
|
||||||
|
if (!visible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
addSome();
|
||||||
|
updateCurrentTrack(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlayQueue::hideLoadingIndicator()
|
||||||
|
{
|
||||||
|
_loadingIndicator = nullptr;
|
||||||
|
bindEmpty("loading-indicator");
|
||||||
|
}
|
||||||
|
|
||||||
Database::TrackList::pointer
|
Database::TrackList::pointer
|
||||||
PlayQueue::getTrackList() const
|
PlayQueue::getTrackList() const
|
||||||
{
|
{
|
||||||
@@ -205,7 +217,7 @@ PlayQueue::clearTracks()
|
|||||||
getTrackList().modify()->clear();
|
getTrackList().modify()->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadingIndicator->setHidden(true);
|
hideLoadingIndicator();
|
||||||
_entriesContainer->clear();
|
_entriesContainer->clear();
|
||||||
updateInfo();
|
updateInfo();
|
||||||
}
|
}
|
||||||
@@ -450,7 +462,10 @@ PlayQueue::addSome()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadingIndicator->setHidden(static_cast<std::size_t>(_entriesContainer->count()) >= tracklist->getCount());
|
if (static_cast<std::size_t>(_entriesContainer->count()) < tracklist->getCount())
|
||||||
|
displayLoadingIndicator();
|
||||||
|
else
|
||||||
|
hideLoadingIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ class PlayQueue : public Wt::WTemplate
|
|||||||
void updateCurrentTrack(bool selected);
|
void updateCurrentTrack(bool selected);
|
||||||
void updateRepeatBtn();
|
void updateRepeatBtn();
|
||||||
void updateRadioBtn();
|
void updateRadioBtn();
|
||||||
|
void displayLoadingIndicator();
|
||||||
|
void hideLoadingIndicator();
|
||||||
|
|
||||||
void loadTrack(std::size_t pos, bool play);
|
void loadTrack(std::size_t pos, bool play);
|
||||||
void stop();
|
void stop();
|
||||||
|
|||||||
@@ -76,15 +76,7 @@ Artists::Artists(Filters* filters)
|
|||||||
_linkType->changed().connect([this] { refreshView(); });
|
_linkType->changed().connect([this] { refreshView(); });
|
||||||
|
|
||||||
_container = bindNew<Wt::WContainerWidget>("artists");
|
_container = bindNew<Wt::WContainerWidget>("artists");
|
||||||
|
hideLoadingIndicator();
|
||||||
_loadingIndicator = bindWidget<Wt::WTemplate>("loading-indicator", createLoadingIndicator());
|
|
||||||
_loadingIndicator->scrollVisibilityChanged().connect([this](bool visible)
|
|
||||||
{
|
|
||||||
if (!visible)
|
|
||||||
return;
|
|
||||||
|
|
||||||
addSome();
|
|
||||||
});
|
|
||||||
|
|
||||||
refreshView();
|
refreshView();
|
||||||
|
|
||||||
@@ -106,6 +98,26 @@ Artists::refreshView(Mode mode)
|
|||||||
refreshView();
|
refreshView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Artists::displayLoadingIndicator()
|
||||||
|
{
|
||||||
|
_loadingIndicator = bindWidget<Wt::WTemplate>("loading-indicator", createLoadingIndicator());
|
||||||
|
_loadingIndicator->scrollVisibilityChanged().connect([this](bool visible)
|
||||||
|
{
|
||||||
|
if (!visible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
addSome();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Artists::hideLoadingIndicator()
|
||||||
|
{
|
||||||
|
_loadingIndicator = nullptr;
|
||||||
|
bindEmpty("loading-indicator");
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Artist::pointer>
|
std::vector<Artist::pointer>
|
||||||
Artists::getRandomArtists(std::optional<Range> range, bool& moreResults)
|
Artists::getRandomArtists(std::optional<Range> range, bool& moreResults)
|
||||||
{
|
{
|
||||||
@@ -207,7 +219,10 @@ Artists::addSome()
|
|||||||
_container->addWidget(ArtistListHelpers::createEntry(artist));
|
_container->addWidget(ArtistListHelpers::createEntry(artist));
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadingIndicator->setHidden(!moreResults);
|
if (moreResults)
|
||||||
|
displayLoadingIndicator();
|
||||||
|
else
|
||||||
|
hideLoadingIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ class Artists : public Wt::WTemplate
|
|||||||
|
|
||||||
void refreshView();
|
void refreshView();
|
||||||
void refreshView(Mode mode);
|
void refreshView(Mode mode);
|
||||||
|
void displayLoadingIndicator();
|
||||||
|
void hideLoadingIndicator();
|
||||||
void addSome();
|
void addSome();
|
||||||
|
|
||||||
std::vector<Wt::Dbo::ptr<Database::Artist>> getArtists(std::optional<Database::Range> range, bool& moreResults);
|
std::vector<Wt::Dbo::ptr<Database::Artist>> getArtists(std::optional<Database::Range> range, bool& moreResults);
|
||||||
|
|||||||
@@ -79,15 +79,7 @@ _filters {filters}
|
|||||||
});
|
});
|
||||||
|
|
||||||
_container = bindNew<Wt::WContainerWidget>("releases");
|
_container = bindNew<Wt::WContainerWidget>("releases");
|
||||||
|
hideLoadingIndicator();
|
||||||
_loadingIndicator = bindWidget<Wt::WTemplate>("loading-indicator", createLoadingIndicator());
|
|
||||||
_loadingIndicator->scrollVisibilityChanged().connect([this](bool visible)
|
|
||||||
{
|
|
||||||
if (!visible)
|
|
||||||
return;
|
|
||||||
|
|
||||||
addSome();
|
|
||||||
});
|
|
||||||
|
|
||||||
refreshView(defaultMode);
|
refreshView(defaultMode);
|
||||||
|
|
||||||
@@ -109,6 +101,26 @@ Releases::refreshView(Mode mode)
|
|||||||
refreshView();
|
refreshView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Releases::displayLoadingIndicator()
|
||||||
|
{
|
||||||
|
_loadingIndicator = bindWidget<Wt::WTemplate>("loading-indicator", createLoadingIndicator());
|
||||||
|
_loadingIndicator->scrollVisibilityChanged().connect([this](bool visible)
|
||||||
|
{
|
||||||
|
if (!visible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
addSome();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Releases::hideLoadingIndicator()
|
||||||
|
{
|
||||||
|
_loadingIndicator = nullptr;
|
||||||
|
bindEmpty("loading-indicator");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Releases::addSome()
|
Releases::addSome()
|
||||||
{
|
{
|
||||||
@@ -122,7 +134,10 @@ Releases::addSome()
|
|||||||
_container->addWidget(ReleaseListHelpers::createEntry(release));
|
_container->addWidget(ReleaseListHelpers::createEntry(release));
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadingIndicator->setHidden(!moreResults);
|
if (moreResults)
|
||||||
|
displayLoadingIndicator();
|
||||||
|
else
|
||||||
|
hideLoadingIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Database::Release::pointer>
|
std::vector<Database::Release::pointer>
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ class Releases : public Wt::WTemplate
|
|||||||
|
|
||||||
void refreshView();
|
void refreshView();
|
||||||
void refreshView(Mode mode);
|
void refreshView(Mode mode);
|
||||||
|
void displayLoadingIndicator();
|
||||||
|
void hideLoadingIndicator();
|
||||||
|
|
||||||
void addSome();
|
void addSome();
|
||||||
std::vector<Wt::Dbo::ptr<Database::Release>> getReleases(std::optional<Database::Range> range, bool& moreResults);
|
std::vector<Wt::Dbo::ptr<Database::Release>> getReleases(std::optional<Database::Range> range, bool& moreResults);
|
||||||
|
|||||||
@@ -83,15 +83,7 @@ _filters {filters}
|
|||||||
});
|
});
|
||||||
|
|
||||||
_tracksContainer = bindNew<Wt::WContainerWidget>("tracks");
|
_tracksContainer = bindNew<Wt::WContainerWidget>("tracks");
|
||||||
|
hideLoadingIndicator();
|
||||||
_loadingIndicator = bindWidget<Wt::WTemplate>("loading-indicator", createLoadingIndicator());
|
|
||||||
_loadingIndicator->scrollVisibilityChanged().connect([this](bool visible)
|
|
||||||
{
|
|
||||||
if (!visible)
|
|
||||||
return;
|
|
||||||
|
|
||||||
addSome();
|
|
||||||
});
|
|
||||||
|
|
||||||
filters->updated().connect([this]
|
filters->updated().connect([this]
|
||||||
{
|
{
|
||||||
@@ -116,6 +108,26 @@ Tracks::refreshView(Mode mode)
|
|||||||
refreshView();
|
refreshView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Tracks::displayLoadingIndicator()
|
||||||
|
{
|
||||||
|
_loadingIndicator = bindWidget<Wt::WTemplate>("loading-indicator", createLoadingIndicator());
|
||||||
|
_loadingIndicator->scrollVisibilityChanged().connect([this](bool visible)
|
||||||
|
{
|
||||||
|
if (!visible)
|
||||||
|
return;
|
||||||
|
|
||||||
|
addSome();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Tracks::hideLoadingIndicator()
|
||||||
|
{
|
||||||
|
_loadingIndicator = nullptr;
|
||||||
|
bindEmpty("loading-indicator");
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Database::Track::pointer>
|
std::vector<Database::Track::pointer>
|
||||||
Tracks::getRandomTracks(std::optional<Range> range, bool& moreResults)
|
Tracks::getRandomTracks(std::optional<Range> range, bool& moreResults)
|
||||||
{
|
{
|
||||||
@@ -210,7 +222,10 @@ Tracks::addSome()
|
|||||||
_tracksContainer->addWidget(TrackListHelpers::createEntry(track));
|
_tracksContainer->addWidget(TrackListHelpers::createEntry(track));
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadingIndicator->setHidden(!moreResults);
|
if (moreResults)
|
||||||
|
displayLoadingIndicator();
|
||||||
|
else
|
||||||
|
hideLoadingIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ class Tracks : public Wt::WTemplate
|
|||||||
|
|
||||||
void refreshView();
|
void refreshView();
|
||||||
void refreshView(Mode mode);
|
void refreshView(Mode mode);
|
||||||
|
void displayLoadingIndicator();
|
||||||
|
void hideLoadingIndicator();
|
||||||
void addSome();
|
void addSome();
|
||||||
|
|
||||||
std::vector<Wt::Dbo::ptr<Database::Track>> getRandomTracks(std::optional<Database::Range> range, bool& moreResults);
|
std::vector<Wt::Dbo::ptr<Database::Track>> getRandomTracks(std::optional<Database::Range> range, bool& moreResults);
|
||||||
|
|||||||
Reference in New Issue
Block a user