- auto retry last fm on fail
This commit is contained in:
parent
36be257462
commit
fa29020cea
16
src/main.cpp
16
src/main.cpp
|
@ -7,6 +7,7 @@
|
|||
#include <wx/wx.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <thread>
|
||||
|
||||
#include "backend.hpp"
|
||||
|
@ -50,17 +51,22 @@ void initLastFM(bool checkMode = false) {
|
|||
lastfm = new LastFM(settings.lastfm.username, settings.lastfm.password, settings.lastfm.api_key,
|
||||
settings.lastfm.api_secret);
|
||||
LastFM::LASTFM_STATUS status = lastfm->authenticate();
|
||||
if (status && checkMode)
|
||||
wxMessageBox(_("Error authenticating at LastFM!"), _("PlayerLink"), wxOK | wxICON_ERROR);
|
||||
else if (checkMode)
|
||||
if (status) {
|
||||
delete lastfm;
|
||||
lastfm = nullptr;
|
||||
if (checkMode)
|
||||
wxMessageBox(_("Error authenticating at LastFM!"), _("PlayerLink"), wxOK | wxICON_ERROR);
|
||||
} else if (checkMode)
|
||||
wxMessageBox(_("The LastFM authentication was successful."), _("PlayerLink"), wxOK | wxICON_INFORMATION);
|
||||
}
|
||||
|
||||
void handleMediaTasks() {
|
||||
initLastFM();
|
||||
int64_t lastMs = 0;
|
||||
while (true) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
if (!lastfm)
|
||||
initLastFM();
|
||||
|
||||
auto mediaInformation = backend::getMediaInformation();
|
||||
auto settings = utils::getSettings();
|
||||
if (!mediaInformation) {
|
||||
|
@ -441,7 +447,6 @@ public:
|
|||
utils::saveSettings(settings);
|
||||
});
|
||||
|
||||
|
||||
wxBitmapButton* addButton = new wxBitmapButton(panel, wxID_ANY, add_button_texture);
|
||||
addButton->SetToolTip(_("Add application"));
|
||||
addButton->Bind(wxEVT_BUTTON, [this, panel, frameSizer, size, delete_button_texture, edit_button_texture,
|
||||
|
@ -462,7 +467,6 @@ public:
|
|||
delete app;
|
||||
});
|
||||
|
||||
|
||||
checkboxRowSizer->Add(anyOtherCheckbox, 1, wxALL | wxALIGN_CENTER_VERTICAL);
|
||||
checkboxRowSizer->Add(addButton, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 5);
|
||||
|
||||
|
|
Loading…
Reference in New Issue