Fixed a couple other missing MessageQueue broadcasts for serialized

queries. We should be good now.
This commit is contained in:
casey langen 2020-10-06 23:15:17 -07:00
parent c88942569b
commit 382cfb0711
4 changed files with 26 additions and 8 deletions

View File

@ -153,13 +153,17 @@ bool AppendPlaylistQuery::OnRun(musik::core::db::Connection &db) {
transaction.CommitAndRestart();
this->library->GetMessageQueue().Broadcast(
Message::Create(nullptr, message::PlaylistModified, playlistId));
this->SendPlaylistMutationBroadcast();
this->result = true;
return true;
}
void AppendPlaylistQuery::SendPlaylistMutationBroadcast() {
this->library->GetMessageQueue().Broadcast(
Message::Create(nullptr, message::PlaylistModified, playlistId));
}
/* ISerializableQuery */
std::string AppendPlaylistQuery::SerializeQuery() {
@ -182,8 +186,11 @@ std::string AppendPlaylistQuery::SerializeResult() {
void AppendPlaylistQuery::DeserializeResult(const std::string& data) {
auto input = nlohmann::json::parse(data);
this->SetStatus(input["result"].get<bool>() == true
? IQuery::Finished : IQuery::Failed);
this->result = input["result"].get<bool>();
this->SetStatus(result ? IQuery::Finished : IQuery::Failed);
if (result) {
SendPlaylistMutationBroadcast();
}
}
std::shared_ptr<AppendPlaylistQuery> AppendPlaylistQuery::DeserializeQuery(

View File

@ -71,6 +71,9 @@ namespace musik { namespace core { namespace library { namespace query {
protected:
virtual bool OnRun(musik::core::db::Connection &db);
private:
void SendPlaylistMutationBroadcast();
musik::core::ILibraryPtr library;
std::shared_ptr<musik::core::TrackList> sharedTracks;
musik::core::sdk::ITrackList* rawTracks;

View File

@ -84,14 +84,17 @@ bool DeletePlaylistQuery::OnRun(musik::core::db::Connection &db) {
this->result = false;
}
else {
this->library->GetMessageQueue().Broadcast(
Message::Create(nullptr, message::PlaylistDeleted, playlistId));
this->SendPlaylistMutationBroadcast();
this->result = true;
}
}
return this->result;
}
void DeletePlaylistQuery::SendPlaylistMutationBroadcast() {
this->library->GetMessageQueue().Broadcast(
Message::Create(nullptr, message::PlaylistModified, playlistId));
}
/* ISerializableQuery */
@ -112,8 +115,11 @@ std::string DeletePlaylistQuery::SerializeResult() {
void DeletePlaylistQuery::DeserializeResult(const std::string& data) {
auto input = nlohmann::json::parse(data);
this->SetStatus(input["result"].get<bool>() == true
? IQuery::Finished : IQuery::Failed);
this->result = input["result"].get<bool>();
this->SetStatus(result ? IQuery::Finished : IQuery::Failed);
if (this->result) {
this->SendPlaylistMutationBroadcast();
}
}
std::shared_ptr<DeletePlaylistQuery> DeletePlaylistQuery::DeserializeQuery(

View File

@ -63,6 +63,8 @@ namespace musik { namespace core { namespace library { namespace query {
virtual bool OnRun(musik::core::db::Connection &db);
private:
void SendPlaylistMutationBroadcast();
int64_t playlistId;
musik::core::ILibraryPtr library;
bool result{ false };