mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 12:34:37 +03:00
fix: update too much times when update all groups
This commit is contained in:
committed by
arm64v8a
parent
f0263e114f
commit
c12199e4aa
@@ -651,32 +651,32 @@ bool UI_update_all_groups_Updating = false;
|
|||||||
#define should_skip_group(g) (g == nullptr || g->url.isEmpty() || g->archive || (onlyAllowed && g->skip_auto_update))
|
#define should_skip_group(g) (g == nullptr || g->url.isEmpty() || g->archive || (onlyAllowed && g->skip_auto_update))
|
||||||
|
|
||||||
void serialUpdateSubscription(const QList<int> &groupsTabOrder, int _order, bool onlyAllowed) {
|
void serialUpdateSubscription(const QList<int> &groupsTabOrder, int _order, bool onlyAllowed) {
|
||||||
// calculate next group
|
if (_order >= groupsTabOrder.size()) {
|
||||||
int nextOrder = _order;
|
|
||||||
std::shared_ptr<NekoGui::Group> nextGroup;
|
|
||||||
forever {
|
|
||||||
nextOrder += 1;
|
|
||||||
if (nextOrder >= groupsTabOrder.size()) break;
|
|
||||||
auto nextGid = groupsTabOrder[nextOrder];
|
|
||||||
nextGroup = NekoGui::profileManager->GetGroup(nextGid);
|
|
||||||
if (should_skip_group(nextGroup)) continue;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate this group
|
|
||||||
auto group = NekoGui::profileManager->GetGroup(groupsTabOrder[_order]);
|
|
||||||
if (group == nullptr) {
|
|
||||||
UI_update_all_groups_Updating = false;
|
UI_update_all_groups_Updating = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// v2.2: listener is moved to GroupItem, no refresh here.
|
// calculate this group
|
||||||
NekoGui_sub::groupUpdater->AsyncUpdate(group->url, group->id, [=] {
|
auto group = NekoGui::profileManager->GetGroup(groupsTabOrder[_order]);
|
||||||
if (nextGroup == nullptr) {
|
if (group == nullptr || should_skip_group(group)) {
|
||||||
UI_update_all_groups_Updating = false;
|
serialUpdateSubscription(groupsTabOrder, _order + 1, onlyAllowed);
|
||||||
} else {
|
return;
|
||||||
serialUpdateSubscription(groupsTabOrder, nextOrder, onlyAllowed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int nextOrder = _order + 1;
|
||||||
|
while (nextOrder < groupsTabOrder.size()) {
|
||||||
|
auto nextGid = groupsTabOrder[nextOrder];
|
||||||
|
auto nextGroup = NekoGui::profileManager->GetGroup(nextGid);
|
||||||
|
if (!should_skip_group(nextGroup)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nextOrder += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Async update current group
|
||||||
|
UI_update_all_groups_Updating = true;
|
||||||
|
NekoGui_sub::groupUpdater->AsyncUpdate(group->url, group->id, [=] {
|
||||||
|
serialUpdateSubscription(groupsTabOrder, nextOrder, onlyAllowed);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -685,13 +685,7 @@ void UI_update_all_groups(bool onlyAllowed) {
|
|||||||
MW_show_log("The last subscription update has not exited.");
|
MW_show_log("The last subscription update has not exited.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// first: freeze group order
|
|
||||||
auto groupsTabOrder = NekoGui::profileManager->groupsTabOrder;
|
auto groupsTabOrder = NekoGui::profileManager->groupsTabOrder;
|
||||||
for (const auto &gid: groupsTabOrder) {
|
serialUpdateSubscription(groupsTabOrder, 0, onlyAllowed);
|
||||||
auto group = NekoGui::profileManager->GetGroup(gid);
|
|
||||||
if (should_skip_group(group)) continue;
|
|
||||||
// start
|
|
||||||
UI_update_all_groups_Updating = true;
|
|
||||||
serialUpdateSubscription(groupsTabOrder, groupsTabOrder.indexOf(gid), onlyAllowed);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user