kopia lustrzana https://gitlab.com/mysocialportal/relatica
Fix update followed/following prunes no longer followed people initiated from outside app
rodzic
8377f640b6
commit
2423dfbddf
|
@ -39,7 +39,7 @@ class ConnectionsManager extends ChangeNotifier {
|
|||
);
|
||||
}
|
||||
|
||||
bool addAllConnections(Iterable<Connection> newConnections) {
|
||||
bool upsertAllConnections(Iterable<Connection> newConnections) {
|
||||
newConnections.forEach(upsertConnection);
|
||||
return true;
|
||||
}
|
||||
|
@ -144,11 +144,13 @@ class ConnectionsManager extends ChangeNotifier {
|
|||
final results = <String, Connection>{};
|
||||
var moreResults = true;
|
||||
var maxId = -1;
|
||||
const limit = 200;
|
||||
const limit = 50;
|
||||
var currentPage = PagingData(limit: limit);
|
||||
final originalContacts = conRepo.getMyContacts().toSet();
|
||||
while (moreResults) {
|
||||
await client.getMyFollowers(currentPage).match(onSuccess: (followers) {
|
||||
for (final f in followers.data) {
|
||||
originalContacts.remove(f);
|
||||
results[f.id] = f.copy(status: ConnectionStatus.theyFollowYou);
|
||||
int id = int.parse(f.id);
|
||||
maxId = max(maxId, id);
|
||||
|
@ -167,6 +169,7 @@ class ConnectionsManager extends ChangeNotifier {
|
|||
while (moreResults) {
|
||||
await client.getMyFollowing(currentPage).match(onSuccess: (following) {
|
||||
for (final f in following.data) {
|
||||
originalContacts.remove(f);
|
||||
if (results.containsKey(f.id)) {
|
||||
results[f.id] = f.copy(status: ConnectionStatus.mutual);
|
||||
} else {
|
||||
|
@ -184,7 +187,11 @@ class ConnectionsManager extends ChangeNotifier {
|
|||
});
|
||||
}
|
||||
|
||||
addAllConnections(results.values);
|
||||
for (final noLongerFollowed in originalContacts) {
|
||||
results[noLongerFollowed.id] =
|
||||
noLongerFollowed.copy(status: ConnectionStatus.none);
|
||||
}
|
||||
upsertAllConnections(results.values);
|
||||
final myContacts = conRepo.getMyContacts().toList();
|
||||
myContacts.sort((c1, c2) => c1.name.compareTo(c2.name));
|
||||
_logger.fine('# Contacts:${myContacts.length}');
|
||||
|
|
Ładowanie…
Reference in New Issue