use of im.actor.core.api.ApiUser in project actor-platform by actorapp.
the class User method editName.
public User editName(@NotNull String name) {
ApiUser w = getWrapped();
ApiUser res = new ApiUser(w.getId(), w.getAccessHash(), name, w.getLocalName(), w.getNick(), w.getSex(), w.getAvatar(), w.isBot(), w.getExt());
res.setUnmappedObjects(w.getUnmappedObjects());
return new User(res, getWrappedExt());
}
use of im.actor.core.api.ApiUser in project actor-platform by actorapp.
the class ContactsSyncActor method onContactsLoaded.
public void onContactsLoaded(ResponseGetContacts result) {
if (ENABLE_LOG) {
Log.d(TAG, "Sync result received");
}
isInProgress = false;
context().getConductor().getConductor().onContactsLoaded();
if (result.isNotChanged()) {
Log.d(TAG, "Sync: Not changed");
if (isInvalidated) {
performSync();
} else {
// ProfileSyncState.onContactsLoaded(contactUsers.size() == 0);
}
return;
}
// Reading all uids
HashSet<Integer> uids = new HashSet<>();
for (ApiUser u : result.getUsers()) {
uids.add(u.getId());
}
for (ApiUserOutPeer u : result.getUserPeers()) {
uids.add(u.getUid());
}
if (ENABLE_LOG) {
Log.d(TAG, "Sync received " + uids.size() + " contacts");
}
outer: for (Integer uid : contacts.toArray(new Integer[contacts.size()])) {
for (Integer u : uids) {
if (u.equals(uid)) {
continue outer;
}
}
if (ENABLE_LOG) {
Log.d(TAG, "Removing: #" + uid);
}
contacts.remove((Integer) uid);
if (getUser(uid) != null) {
getUserVM(uid).isContact().change(false);
}
context().getContactsModule().markNonContact(uid);
}
for (Integer u : uids) {
if (contacts.contains(u)) {
continue;
}
if (ENABLE_LOG) {
Log.d(TAG, "Adding: #" + u);
}
contacts.add(u);
if (getUser(u) != null) {
getUserVM(u).isContact().change(true);
}
context().getContactsModule().markContact(u);
}
saveList();
updateEngineList();
if (isInvalidated) {
self().send(new PerformSync());
}
}
use of im.actor.core.api.ApiUser in project actor-platform by actorapp.
the class SequenceHandlerActor method onDifferenceUpdate.
private Promise<Void> onDifferenceUpdate(@NotNull List<ApiUser> users, @NotNull List<ApiGroup> groups, @NotNull List<ApiUserOutPeer> userOutPeers, @NotNull List<ApiGroupOutPeer> groupOutPeers, @NotNull List<Update> updates) {
if (updates.size() > 0) {
String command = "Difference updates:";
for (Update u : updates) {
command += "\n| " + u;
}
Log.d(TAG, command);
}
beginUpdates();
// Related Users
Promise<Void> currentPromise = updates().applyRelatedData(users, groups);
// Loading missing peers
currentPromise = currentPromise.chain(v -> updates().loadRequiredPeers(userOutPeers, groupOutPeers));
// Apply Diff
long applyStart = im.actor.runtime.Runtime.getCurrentTime();
currentPromise = currentPromise.chain(v -> processor.applyDifferenceUpdate(updates)).then(v -> {
Log.d(TAG, "Difference applied in " + (im.actor.runtime.Runtime.getCurrentTime() - applyStart) + " ms");
endUpdates();
});
return currentPromise;
}
Aggregations