NOISSUE fix builds, make account refresh queue user friendly
This commit is contained in:
parent
db6431d9e0
commit
d37003b1de
@ -635,21 +635,33 @@ void AccountList::fillQueue() {
|
||||
|
||||
if(account->shouldRefresh()) {
|
||||
auto idToRefresh = account->internalId();
|
||||
m_refreshQueue.push_back(idToRefresh);
|
||||
qDebug() << "AccountList: Queued account with internal ID " << idToRefresh << " to refresh";
|
||||
queueRefresh(idToRefresh);
|
||||
}
|
||||
}
|
||||
m_refreshQueue.removeDuplicates();
|
||||
tryNext();
|
||||
}
|
||||
|
||||
void AccountList::requestRefresh(QString accountId) {
|
||||
m_refreshQueue.push_back(accountId);
|
||||
auto index = m_refreshQueue.indexOf(accountId);
|
||||
if(index != -1) {
|
||||
m_refreshQueue.removeAt(index);
|
||||
}
|
||||
m_refreshQueue.push_front(accountId);
|
||||
qDebug() << "AccountList: Pushed account with internal ID " << accountId << " to the front of the queue";
|
||||
if(!isActive()) {
|
||||
tryNext();
|
||||
}
|
||||
}
|
||||
|
||||
void AccountList::queueRefresh(QString accountId) {
|
||||
if(m_refreshQueue.indexOf(accountId) != -1) {
|
||||
return;
|
||||
}
|
||||
m_refreshQueue.push_back(accountId);
|
||||
qDebug() << "AccountList: Queued account with internal ID " << accountId << " to refresh";
|
||||
}
|
||||
|
||||
|
||||
void AccountList::tryNext() {
|
||||
beginActivity();
|
||||
while (m_refreshQueue.length()) {
|
||||
@ -672,21 +684,21 @@ void AccountList::tryNext() {
|
||||
}
|
||||
endActivity();
|
||||
// if we get here, no account needed refreshing. Schedule refresh in an hour.
|
||||
m_refreshTimer->start(std::chrono::hours(1));
|
||||
m_refreshTimer->start(1000 * 3600);
|
||||
}
|
||||
|
||||
void AccountList::authSucceeded() {
|
||||
qDebug() << "RefreshSchedule: Background account refresh succeeded";
|
||||
m_currentTask.reset();
|
||||
endActivity();
|
||||
m_nextTimer->start(std::chrono::seconds(20));
|
||||
m_nextTimer->start(1000 * 20);
|
||||
}
|
||||
|
||||
void AccountList::authFailed(QString reason) {
|
||||
qDebug() << "RefreshSchedule: Background account refresh failed: " << reason;
|
||||
m_currentTask.reset();
|
||||
endActivity();
|
||||
m_nextTimer->start(std::chrono::seconds(20));
|
||||
m_nextTimer->start(1000 * 20);
|
||||
}
|
||||
|
||||
bool AccountList::isActive() const {
|
||||
|
@ -67,7 +67,10 @@ public:
|
||||
MinecraftAccountPtr getAccountByProfileName(const QString &profileName) const;
|
||||
QStringList profileNames() const;
|
||||
|
||||
// requesting a refresh pushes it to the front of the queue
|
||||
void requestRefresh(QString accountId);
|
||||
// queuing a refresh will let it go to the back of the queue (unless it's somewhere inside the queue already)
|
||||
void queueRefresh(QString accountId);
|
||||
|
||||
/*!
|
||||
* Sets the path to load/save the list file from/to.
|
||||
|
@ -211,7 +211,7 @@ bool MinecraftAccount::shouldRefresh() const {
|
||||
if(!expiresTimestamp.isValid()) {
|
||||
expiresTimestamp = issuedTimestamp.addSecs(24 * 3600);
|
||||
}
|
||||
if (now.secsTo(expiresTimestamp) < 12 * 3600) {
|
||||
if (now.secsTo(expiresTimestamp) < (12 * 3600)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user