mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 04:18:36 +00:00
Fixed a couple other missing MessageQueue broadcasts for serialized
queries. We should be good now.
This commit is contained in:
parent
c88942569b
commit
382cfb0711
@ -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(
|
||||
|
@ -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;
|
||||
|
@ -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(
|
||||
|
@ -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 };
|
||||
|
Loading…
x
Reference in New Issue
Block a user