Migrated current play counter in ui states
This commit is contained in:
@@ -758,6 +758,7 @@ SELECT
|
||||
|
||||
session.getDboSession()->execute("ALTER TABLE user DROP COLUMN repeat_all");
|
||||
session.getDboSession()->execute("ALTER TABLE user DROP COLUMN radio");
|
||||
session.getDboSession()->execute("ALTER TABLE user DROP COLUMN cur_playing_track_pos");
|
||||
}
|
||||
|
||||
bool doDbMigration(Session& session)
|
||||
|
||||
@@ -105,7 +105,6 @@ namespace lms::db
|
||||
void setSubsonicEnableTranscodingByDefault(bool value) { _subsonicEnableTranscodingByDefault = value; }
|
||||
void setSubsonicDefaultTranscodintOutputFormat(TranscodingOutputFormat encoding) { _subsonicDefaultTranscodingOutputFormat = encoding; }
|
||||
void setSubsonicDefaultTranscodingOutputBitrate(Bitrate bitrate);
|
||||
void setCurPlayingTrackPos(std::size_t pos) { _curPlayingTrackPos = pos; }
|
||||
void setUITheme(UITheme uiTheme) { _uiTheme = uiTheme; }
|
||||
void clearAuthTokens();
|
||||
void setSubsonicArtistListMode(SubsonicArtistListMode mode) { _subsonicArtistListMode = mode; }
|
||||
@@ -120,7 +119,6 @@ namespace lms::db
|
||||
bool getSubsonicEnableTranscodingByDefault() const { return _subsonicEnableTranscodingByDefault; }
|
||||
TranscodingOutputFormat getSubsonicDefaultTranscodingOutputFormat() const { return _subsonicDefaultTranscodingOutputFormat; }
|
||||
Bitrate getSubsonicDefaultTranscodingOutputBitrate() const { return _subsonicDefaultTranscodingOutputBitrate; }
|
||||
std::size_t getCurPlayingTrackPos() const { return _curPlayingTrackPos; }
|
||||
UITheme getUITheme() const { return _uiTheme; }
|
||||
SubsonicArtistListMode getSubsonicArtistListMode() const { return _subsonicArtistListMode; }
|
||||
FeedbackBackend getFeedbackBackend() const { return _feedbackBackend; }
|
||||
@@ -144,11 +142,8 @@ namespace lms::db
|
||||
Wt::Dbo::field(a, _scrobblingBackend, "scrobbling_backend");
|
||||
Wt::Dbo::field(a, _listenbrainzToken, "listenbrainz_token");
|
||||
|
||||
// UI player settings
|
||||
Wt::Dbo::field(a, _curPlayingTrackPos, "cur_playing_track_pos");
|
||||
|
||||
Wt::Dbo::hasMany(a, _authTokens, Wt::Dbo::ManyToOne, "user");
|
||||
Wt::Dbo::hasMany(a, _uiSettings, Wt::Dbo::ManyToOne, "user");
|
||||
Wt::Dbo::hasMany(a, _uiStates, Wt::Dbo::ManyToOne, "user");
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -174,11 +169,8 @@ namespace lms::db
|
||||
TranscodingOutputFormat _subsonicDefaultTranscodingOutputFormat{ defaultSubsonicTranscodingOutputFormat };
|
||||
int _subsonicDefaultTranscodingOutputBitrate{ defaultSubsonicTranscodingOutputBitrate };
|
||||
|
||||
// User's dynamic data (UI)
|
||||
int _curPlayingTrackPos{}; // Current track position in queue
|
||||
|
||||
Wt::Dbo::collection<Wt::Dbo::ptr<AuthToken>> _authTokens;
|
||||
Wt::Dbo::collection<Wt::Dbo::ptr<UIState>> _uiSettings;
|
||||
Wt::Dbo::collection<Wt::Dbo::ptr<UIState>> _uiStates;
|
||||
};
|
||||
|
||||
} // namespace lms::db
|
||||
|
||||
@@ -186,21 +186,15 @@ namespace lms::ui
|
||||
|
||||
_mediaPlayerSettingsLoaded = true;
|
||||
|
||||
std::size_t trackPos{};
|
||||
|
||||
{
|
||||
auto transaction{ LmsApp->getDbSession().createReadTransaction() };
|
||||
trackPos = LmsApp->getUser()->getCurPlayingTrackPos();
|
||||
}
|
||||
|
||||
const std::size_t trackPos{ state::readValue<size_t>("player_cur_playing_track_pos").value_or(0) };
|
||||
loadTrack(trackPos, false);
|
||||
});
|
||||
|
||||
LmsApp->preQuit().connect([this] {
|
||||
auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
|
||||
|
||||
if (LmsApp->getUser()->isDemo())
|
||||
if (LmsApp->getUserType() == db::UserType::DEMO)
|
||||
{
|
||||
auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
|
||||
|
||||
LMS_LOG(UI, DEBUG, "Removing queue (tracklist id " << _queueId.toString() << ")");
|
||||
if (db::TrackList::pointer queue{ getQueue() })
|
||||
queue.remove();
|
||||
@@ -258,7 +252,7 @@ namespace lms::ui
|
||||
db::TrackId trackId{};
|
||||
std::optional<float> replayGain{};
|
||||
{
|
||||
auto transaction{ LmsApp->getDbSession().createWriteTransaction() };
|
||||
auto transaction{ LmsApp->getDbSession().createReadTransaction() };
|
||||
|
||||
const db::TrackList::pointer queue{ getQueue() };
|
||||
|
||||
@@ -275,16 +269,14 @@ namespace lms::ui
|
||||
}
|
||||
|
||||
_trackPos = pos;
|
||||
|
||||
const db::Track::pointer track{ queue->getEntry(*_trackPos)->getTrack() };
|
||||
|
||||
trackId = track->getId();
|
||||
|
||||
replayGain = getReplayGain(pos, track);
|
||||
|
||||
if (!LmsApp->getUser()->isDemo())
|
||||
LmsApp->getUser().modify()->setCurPlayingTrackPos(pos);
|
||||
}
|
||||
|
||||
state::writeValue<size_t>("player_cur_playing_track_pos", pos);
|
||||
|
||||
enqueueRadioTracksIfNeeded();
|
||||
updateCurrentTrack(true);
|
||||
_isTrackSelected = true;
|
||||
@@ -331,7 +323,7 @@ namespace lms::ui
|
||||
db::TrackList::pointer queue;
|
||||
db::TrackList::pointer radioStartingTracks;
|
||||
|
||||
if (!LmsApp->getUser()->isDemo())
|
||||
if (LmsApp->getUserType() != db::UserType::DEMO)
|
||||
{
|
||||
static const std::string queueName{ "__queued_tracks__" };
|
||||
queue = db::TrackList::find(LmsApp->getDbSession(), queueName, db::TrackListType::Internal, LmsApp->getUserId());
|
||||
|
||||
@@ -547,9 +547,7 @@ namespace lms::ui
|
||||
|
||||
saveBtn->clicked().connect([=] {
|
||||
{
|
||||
auto transaction{ LmsApp->getDbSession().createReadTransaction() };
|
||||
|
||||
if (LmsApp->getUser()->isDemo())
|
||||
if (LmsApp->getUserType() == db::UserType::DEMO)
|
||||
{
|
||||
LmsApp->notifyMsg(Notification::Type::Warning, Wt::WString::tr("Lms.Settings.settings"), Wt::WString::tr("Lms.Settings.demo-cannot-save"));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user