Skip to content

Commit

Permalink
Make new paging default, fixes #102
Browse files Browse the repository at this point in the history
  • Loading branch information
kraxarn committed Nov 11, 2023
1 parent 6b5a769 commit 5ad1fa3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 57 deletions.
1 change: 0 additions & 1 deletion lib/include/lib/enum/experiment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ namespace lib
*/
enum class experiment
{
new_paging = 1,
};
}
5 changes: 0 additions & 5 deletions src/commandline/args.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,3 @@
* Print system information
*/
#define ARG_SYSTEM_INFORMATION QStringLiteral("system-info")

/**
* Enable new paging experiment with better performance
*/
#define ARG_NEW_PAGING QStringLiteral("experiment-new-paging")
4 changes: 0 additions & 4 deletions src/commandline/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ auto CommandLine::Parser::options() -> QList<QCommandLineOption>
ARG_SYSTEM_INFORMATION,
QStringLiteral("Print system information"),
},
{
ARG_NEW_PAGING,
QStringLiteral("Enable new page loading (experimental)"),
},
// Playback options
{
ARG_PLAY_PAUSE,
Expand Down
6 changes: 0 additions & 6 deletions src/commandline/processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ auto CommandLine::Processor::process(const QCommandLineParser &parser) -> bool
if (parser.isSet(ARG_ENABLE_DEV))
{
lib::developer_mode::enabled = true;

if (parser.isSet(ARG_NEW_PAGING))
{
lib::developer_mode::add_experiment(lib::experiment::new_paging);
}

return false;
}

Expand Down
67 changes: 26 additions & 41 deletions src/list/tracks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,56 +662,41 @@ void List::Tracks::refreshPlaylist(const lib::spt::playlist &playlist)
{
auto *mainWindow = MainWindow::find(parentWidget());

if (lib::developer_mode::is_experiment_enabled(lib::experiment::new_paging))
const auto playlistUri = lib::spt::id_to_uri("playlist", playlist.id);
if (refreshing && playlistUri == mainWindow->history()->currentUri())
{
const auto playlistUri = lib::spt::id_to_uri("playlist", playlist.id);
if (refreshing && playlistUri == mainWindow->history()->currentUri())
{
return;
}
return;
}

refreshing = true;
refreshing = true;

spotify.playlist_tracks(playlist,
[this, mainWindow, playlist, playlistUri]
(const lib::result<lib::spt::page<lib::spt::track>> &result) -> bool
{
if (playlistUri != mainWindow->history()->currentUri())
{
refreshing = false;
return false;
}

spotify.playlist_tracks(playlist,
[this, mainWindow, playlist, playlistUri]
(const lib::result<lib::spt::page<lib::spt::track>> &result) -> bool
if (!result.success())
{
if (playlistUri != mainWindow->history()->currentUri())
{
refreshing = false;
return false;
}

if (!result.success())
{
StatusMessage::error(QString("Failed to load playlist: %1")
.arg(QString::fromStdString(result.message())));

refreshing = false;
return false;
}

if (load(result.value()))
{
return true;
}
StatusMessage::error(QString("Failed to load playlist: %1")
.arg(QString::fromStdString(result.message())));

refreshing = false;
saveToCache(playlist);
return false;
});
}

return;
}
if (load(result.value()))
{
return true;
}

spotify.playlist_tracks(playlist,
[this, playlist](const std::vector<lib::spt::track> &tracks)
{
auto newPlaylist = playlist;
newPlaylist.tracks = tracks;
this->load(newPlaylist.tracks);
this->setEnabled(true);
this->cache.set_playlist(newPlaylist);
refreshing = false;
saveToCache(playlist);
return false;
});
}

Expand Down

0 comments on commit 5ad1fa3

Please sign in to comment.