use of im.actor.core.viewmodel.AvatarUploadState in project actor-platform by actorapp.
the class GroupAvatarChangeActor method avatarChanged.
public void avatarChanged(int gid, long rid) {
if (!currentTasks.containsKey(gid)) {
return;
}
if (currentTasks.get(gid) != rid) {
return;
}
currentTasks.remove(gid);
context().getGroupsModule().getAvatarVM(gid).getUploadState().change(new AvatarUploadState(null, false));
}
use of im.actor.core.viewmodel.AvatarUploadState in project actor-platform by actorapp.
the class GroupAvatarChangeActor method uploadError.
public void uploadError(long rid) {
if (!tasksMap.containsKey(rid)) {
return;
}
final int gid = tasksMap.get(rid);
if (currentTasks.get(gid) != rid) {
return;
}
currentTasks.remove(gid);
tasksMap.remove(rid);
context().getGroupsModule().getAvatarVM(gid).getUploadState().change(new AvatarUploadState(null, false));
}
use of im.actor.core.viewmodel.AvatarUploadState in project actor-platform by actorapp.
the class GroupAvatarChangeActor method changeAvatar.
public void changeAvatar(int gid, String descriptor) {
if (currentTasks.containsKey(gid)) {
context().getFilesModule().cancelUpload(currentTasks.get(gid));
currentTasks.remove(gid);
}
long rid = RandomUtils.nextRid();
currentTasks.put(gid, rid);
tasksMap.put(rid, gid);
context().getGroupsModule().getAvatarVM(gid).getUploadState().change(new AvatarUploadState(descriptor, true));
context().getFilesModule().requestUpload(rid, descriptor, "avatar.jpg", self());
}
use of im.actor.core.viewmodel.AvatarUploadState in project actor-platform by actorapp.
the class GroupAvatarChangeActor method removeAvatar.
public void removeAvatar(final int gid) {
if (currentTasks.containsKey(gid)) {
context().getFilesModule().cancelUpload(currentTasks.get(gid));
currentTasks.remove(gid);
}
final long rid = RandomUtils.nextRid();
currentTasks.put(gid, rid);
tasksMap.put(rid, gid);
Group group = context().getGroupsModule().getGroups().getValue(gid);
ApiGroupOutPeer outPeer = new ApiGroupOutPeer(gid, group.getAccessHash());
context().getProfileModule().getOwnAvatarVM().getUploadState().change(new AvatarUploadState(null, true));
api(new RequestRemoveGroupAvatar(outPeer, rid, ApiSupportConfiguration.OPTIMIZATIONS)).flatMap(responseSeqDate -> updates().applyUpdate(responseSeqDate.getSeq(), responseSeqDate.getState(), new UpdateGroupAvatarChangedObsolete(gid, rid, myUid(), null, responseSeqDate.getDate()))).then(aVoid -> avatarChanged(gid, rid)).failure(e -> {
if (!tasksMap.containsKey(rid)) {
return;
}
final int gid2 = tasksMap.get(rid);
if (currentTasks.get(gid) != rid) {
return;
}
currentTasks.remove(gid2);
tasksMap.remove(rid);
context().getGroupsModule().getAvatarVM(gid2).getUploadState().change(new AvatarUploadState(null, false));
});
}
use of im.actor.core.viewmodel.AvatarUploadState in project actor-platform by actorapp.
the class OwnAvatarChangeActor method uploadError.
public void uploadError(long rid) {
if (rid != currentChangeTask) {
return;
}
currentChangeTask = 0;
context().getProfileModule().getOwnAvatarVM().getUploadState().change(new AvatarUploadState(null, false));
}
Aggregations