2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Add an animated scroll to current media message.

This commit is contained in:
John Preston
2017-05-21 20:08:59 +03:00
parent 6bde8cdce4
commit 0bfff65306
4 changed files with 117 additions and 24 deletions

View File

@@ -166,7 +166,7 @@ void Instance::rebuildPlaylist(Data *data) {
_playlistChangedNotifier.notify(data->type, true);
}
bool Instance::moveInPlaylist(Data *data, int delta) {
bool Instance::moveInPlaylist(Data *data, int delta, bool autonext) {
Expects(data != nullptr);
auto index = data->playlist.indexOf(data->current.contextId());
@@ -179,6 +179,9 @@ bool Instance::moveInPlaylist(Data *data, int delta) {
auto msgId = data->playlist[newIndex];
if (auto item = App::histItemById(msgId)) {
if (auto media = item->getMedia()) {
if (autonext) {
_switchToNextNotifier.notify({ data->current, msgId });
}
media->playInline();
return true;
}
@@ -258,14 +261,14 @@ void Instance::playPause(AudioMsgId::Type type) {
bool Instance::next(AudioMsgId::Type type) {
if (auto data = getData(type)) {
return moveInPlaylist(data, 1);
return moveInPlaylist(data, 1, false);
}
return false;
}
bool Instance::previous(AudioMsgId::Type type) {
if (auto data = getData(type)) {
return moveInPlaylist(data, -1);
return moveInPlaylist(data, -1, false);
}
return false;
}
@@ -323,7 +326,7 @@ void Instance::emitUpdate(AudioMsgId::Type type, CheckCallback check) {
if (data->isPlaying && state.state == State::StoppedAtEnd) {
if (data->repeatEnabled) {
play(data->current);
} else if (!next(type)) {
} else if (!moveInPlaylist(data, 1, true)) {
_tracksFinishedNotifier.notify(type);
}
}